get Database
Use this data source to access information about an existing SQL Azure Database.
Note: The
azure.sql.Database
data source is deprecated in version 3.0 of the AzureRM provider and will be removed in version 4.0. Please use theazure.mssql.Database
data source instead.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.sql.getDatabase({
name: "example_db",
serverName: "example_db_server",
resourceGroupName: "example-resources",
});
export const sqlDatabaseId = example.then(example => example.id);
Content copied to clipboard
import pulumi
import pulumi_azure as azure
example = azure.sql.get_database(name="example_db",
server_name="example_db_server",
resource_group_name="example-resources")
pulumi.export("sqlDatabaseId", example.id)
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = Azure.Sql.GetDatabase.Invoke(new()
{
Name = "example_db",
ServerName = "example_db_server",
ResourceGroupName = "example-resources",
});
return new Dictionary<string, object?>
{
["sqlDatabaseId"] = example.Apply(getDatabaseResult => getDatabaseResult.Id),
};
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/sql"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := sql.LookupDatabase(ctx, &sql.LookupDatabaseArgs{
Name: "example_db",
ServerName: "example_db_server",
ResourceGroupName: "example-resources",
}, nil)
if err != nil {
return err
}
ctx.Export("sqlDatabaseId", example.Id)
return nil
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.sql.SqlFunctions;
import com.pulumi.azure.sql.inputs.GetDatabaseArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = SqlFunctions.getDatabase(GetDatabaseArgs.builder()
.name("example_db")
.serverName("example_db_server")
.resourceGroupName("example-resources")
.build());
ctx.export("sqlDatabaseId", example.applyValue(getDatabaseResult -> getDatabaseResult.id()));
}
}
Content copied to clipboard
variables:
example:
fn::invoke:
Function: azure:sql:getDatabase
Arguments:
name: example_db
serverName: example_db_server
resourceGroupName: example-resources
outputs:
sqlDatabaseId: ${example.id}
Content copied to clipboard
Return
A collection of values returned by getDatabase.
Parameters
argument
A collection of arguments for invoking getDatabase.
suspend fun getDatabase(name: String, resourceGroupName: String, serverName: String, tags: Map<String, String>? = null): GetDatabaseResult
Return
A collection of values returned by getDatabase.
Parameters
name
The name of the SQL Database.
resource Group Name
Specifies the name of the Resource Group where the Azure SQL Database exists.
server Name
The name of the SQL Server.
tags
A mapping of tags assigned to the resource.
See also
suspend fun getDatabase(argument: suspend GetDatabasePlainArgsBuilder.() -> Unit): GetDatabaseResult
Return
A collection of values returned by getDatabase.
Parameters
argument
Builder for com.pulumi.azure.sql.kotlin.inputs.GetDatabasePlainArgs.