1. Packages
  2. Azure Classic
  3. API Docs
  4. mssql
  5. getDatabase

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
azure logo

We recommend using Azure Native.

Viewing docs for Azure v4.42.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Use this data source to access information about an existing SQL database.

    Example Usage

    using Pulumi;
    using Azure = Pulumi.Azure;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            var example = Output.Create(Azure.MSSql.GetDatabase.InvokeAsync(new Azure.MSSql.GetDatabaseArgs
            {
                Name = "example-mssql-db",
                ServerId = "example-mssql-server-id",
            }));
            this.DatabaseId = example.Apply(example => example.Id);
        }
    
        [Output("databaseId")]
        public Output<string> DatabaseId { get; set; }
    }
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/mssql"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := mssql.LookupDatabase(ctx, &mssql.LookupDatabaseArgs{
    			Name:     "example-mssql-db",
    			ServerId: "example-mssql-server-id",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("databaseId", example.Id)
    		return nil
    	})
    }
    

    Example coming soon!

    import * as pulumi from "@pulumi/pulumi";
    import * as azure from "@pulumi/azure";
    
    const example = azure.mssql.getDatabase({
        name: "example-mssql-db",
        serverId: "example-mssql-server-id",
    });
    export const databaseId = example.then(example => example.id);
    
    import pulumi
    import pulumi_azure as azure
    
    example = azure.mssql.get_database(name="example-mssql-db",
        server_id="example-mssql-server-id")
    pulumi.export("databaseId", example.id)
    

    Example coming soon!

    Using getDatabase

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getDatabase(args: GetDatabaseArgs, opts?: InvokeOptions): Promise<GetDatabaseResult>
    function getDatabaseOutput(args: GetDatabaseOutputArgs, opts?: InvokeOptions): Output<GetDatabaseResult>
    def get_database(name: Optional[str] = None,
                     server_id: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetDatabaseResult
    def get_database_output(name: Optional[pulumi.Input[str]] = None,
                     server_id: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetDatabaseResult]
    func LookupDatabase(ctx *Context, args *LookupDatabaseArgs, opts ...InvokeOption) (*LookupDatabaseResult, error)
    func LookupDatabaseOutput(ctx *Context, args *LookupDatabaseOutputArgs, opts ...InvokeOption) LookupDatabaseResultOutput

    > Note: This function is named LookupDatabase in the Go SDK.

    public static class GetDatabase 
    {
        public static Task<GetDatabaseResult> InvokeAsync(GetDatabaseArgs args, InvokeOptions? opts = null)
        public static Output<GetDatabaseResult> Invoke(GetDatabaseInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
    public static Output<GetDatabaseResult> getDatabase(GetDatabaseArgs args, InvokeOptions options)
    
    fn::invoke:
      function: azure:mssql/getDatabase:getDatabase
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    The name of the Ms SQL Database.
    ServerId string
    The id of the Ms SQL Server on which to create the database.
    Name string
    The name of the Ms SQL Database.
    ServerId string
    The id of the Ms SQL Server on which to create the database.
    name String
    The name of the Ms SQL Database.
    serverId String
    The id of the Ms SQL Server on which to create the database.
    name string
    The name of the Ms SQL Database.
    serverId string
    The id of the Ms SQL Server on which to create the database.
    name str
    The name of the Ms SQL Database.
    server_id str
    The id of the Ms SQL Server on which to create the database.
    name String
    The name of the Ms SQL Database.
    serverId String
    The id of the Ms SQL Server on which to create the database.

    getDatabase Result

    The following output properties are available:

    Collation string
    The collation of the database.
    ElasticPoolId string
    The id of the elastic pool containing this database.
    Id string
    The provider-assigned unique ID for this managed resource.
    LicenseType string
    The license type to apply for this database.
    MaxSizeGb int
    The max size of the database in gigabytes.
    Name string
    ReadReplicaCount int
    The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed.
    ReadScale bool
    If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica.
    ServerId string
    SkuName string
    The name of the sku of the database.
    StorageAccountType string
    The storage account type used to store backups for this database.
    Tags Dictionary<string, string>
    A mapping of tags to assign to the resource.
    ZoneRedundant bool
    Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
    Collation string
    The collation of the database.
    ElasticPoolId string
    The id of the elastic pool containing this database.
    Id string
    The provider-assigned unique ID for this managed resource.
    LicenseType string
    The license type to apply for this database.
    MaxSizeGb int
    The max size of the database in gigabytes.
    Name string
    ReadReplicaCount int
    The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed.
    ReadScale bool
    If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica.
    ServerId string
    SkuName string
    The name of the sku of the database.
    StorageAccountType string
    The storage account type used to store backups for this database.
    Tags map[string]string
    A mapping of tags to assign to the resource.
    ZoneRedundant bool
    Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
    collation String
    The collation of the database.
    elasticPoolId String
    The id of the elastic pool containing this database.
    id String
    The provider-assigned unique ID for this managed resource.
    licenseType String
    The license type to apply for this database.
    maxSizeGb Integer
    The max size of the database in gigabytes.
    name String
    readReplicaCount Integer
    The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed.
    readScale Boolean
    If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica.
    serverId String
    skuName String
    The name of the sku of the database.
    storageAccountType String
    The storage account type used to store backups for this database.
    tags Map<String,String>
    A mapping of tags to assign to the resource.
    zoneRedundant Boolean
    Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
    collation string
    The collation of the database.
    elasticPoolId string
    The id of the elastic pool containing this database.
    id string
    The provider-assigned unique ID for this managed resource.
    licenseType string
    The license type to apply for this database.
    maxSizeGb number
    The max size of the database in gigabytes.
    name string
    readReplicaCount number
    The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed.
    readScale boolean
    If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica.
    serverId string
    skuName string
    The name of the sku of the database.
    storageAccountType string
    The storage account type used to store backups for this database.
    tags {[key: string]: string}
    A mapping of tags to assign to the resource.
    zoneRedundant boolean
    Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
    collation str
    The collation of the database.
    elastic_pool_id str
    The id of the elastic pool containing this database.
    id str
    The provider-assigned unique ID for this managed resource.
    license_type str
    The license type to apply for this database.
    max_size_gb int
    The max size of the database in gigabytes.
    name str
    read_replica_count int
    The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed.
    read_scale bool
    If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica.
    server_id str
    sku_name str
    The name of the sku of the database.
    storage_account_type str
    The storage account type used to store backups for this database.
    tags Mapping[str, str]
    A mapping of tags to assign to the resource.
    zone_redundant bool
    Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
    collation String
    The collation of the database.
    elasticPoolId String
    The id of the elastic pool containing this database.
    id String
    The provider-assigned unique ID for this managed resource.
    licenseType String
    The license type to apply for this database.
    maxSizeGb Number
    The max size of the database in gigabytes.
    name String
    readReplicaCount Number
    The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed.
    readScale Boolean
    If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica.
    serverId String
    skuName String
    The name of the sku of the database.
    storageAccountType String
    The storage account type used to store backups for this database.
    tags Map<String>
    A mapping of tags to assign to the resource.
    zoneRedundant Boolean
    Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.

    Package Details

    Repository
    Azure Classic pulumi/pulumi-azure
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the azurerm Terraform Provider.
    azure logo

    We recommend using Azure Native.

    Viewing docs for Azure v4.42.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.