We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
Manages a SQL Database within a Cosmos DB Account.
Example Usage
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var exampleAccount = Output.Create(Azure.CosmosDB.GetAccount.InvokeAsync(new Azure.CosmosDB.GetAccountArgs
{
Name = "tfex-cosmosdb-account",
ResourceGroupName = "tfex-cosmosdb-account-rg",
}));
var exampleSqlDatabase = new Azure.CosmosDB.SqlDatabase("exampleSqlDatabase", new Azure.CosmosDB.SqlDatabaseArgs
{
ResourceGroupName = exampleAccount.Apply(exampleAccount => exampleAccount.ResourceGroupName),
AccountName = exampleAccount.Apply(exampleAccount => exampleAccount.Name),
Throughput = 400,
});
}
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/cosmosdb"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleAccount, err := cosmosdb.LookupAccount(ctx, &cosmosdb.LookupAccountArgs{
Name: "tfex-cosmosdb-account",
ResourceGroupName: "tfex-cosmosdb-account-rg",
}, nil)
if err != nil {
return err
}
_, err = cosmosdb.NewSqlDatabase(ctx, "exampleSqlDatabase", &cosmosdb.SqlDatabaseArgs{
ResourceGroupName: pulumi.String(exampleAccount.ResourceGroupName),
AccountName: pulumi.String(exampleAccount.Name),
Throughput: pulumi.Int(400),
})
if err != nil {
return err
}
return nil
})
}
Example coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleAccount = azure.cosmosdb.getAccount({
name: "tfex-cosmosdb-account",
resourceGroupName: "tfex-cosmosdb-account-rg",
});
const exampleSqlDatabase = new azure.cosmosdb.SqlDatabase("exampleSqlDatabase", {
resourceGroupName: exampleAccount.then(exampleAccount => exampleAccount.resourceGroupName),
accountName: exampleAccount.then(exampleAccount => exampleAccount.name),
throughput: 400,
});
import pulumi
import pulumi_azure as azure
example_account = azure.cosmosdb.get_account(name="tfex-cosmosdb-account",
resource_group_name="tfex-cosmosdb-account-rg")
example_sql_database = azure.cosmosdb.SqlDatabase("exampleSqlDatabase",
resource_group_name=example_account.resource_group_name,
account_name=example_account.name,
throughput=400)
Example coming soon!
Create SqlDatabase Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SqlDatabase(name: string, args: SqlDatabaseArgs, opts?: CustomResourceOptions);@overload
def SqlDatabase(resource_name: str,
args: SqlDatabaseArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SqlDatabase(resource_name: str,
opts: Optional[ResourceOptions] = None,
account_name: Optional[str] = None,
resource_group_name: Optional[str] = None,
autoscale_settings: Optional[SqlDatabaseAutoscaleSettingsArgs] = None,
name: Optional[str] = None,
throughput: Optional[int] = None)func NewSqlDatabase(ctx *Context, name string, args SqlDatabaseArgs, opts ...ResourceOption) (*SqlDatabase, error)public SqlDatabase(string name, SqlDatabaseArgs args, CustomResourceOptions? opts = null)
public SqlDatabase(String name, SqlDatabaseArgs args)
public SqlDatabase(String name, SqlDatabaseArgs args, CustomResourceOptions options)
type: azure:cosmosdb:SqlDatabase
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SqlDatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SqlDatabaseArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SqlDatabaseArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SqlDatabaseArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SqlDatabaseArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var sqlDatabaseResource = new Azure.CosmosDB.SqlDatabase("sqlDatabaseResource", new()
{
AccountName = "string",
ResourceGroupName = "string",
AutoscaleSettings = new Azure.CosmosDB.Inputs.SqlDatabaseAutoscaleSettingsArgs
{
MaxThroughput = 0,
},
Name = "string",
Throughput = 0,
});
example, err := cosmosdb.NewSqlDatabase(ctx, "sqlDatabaseResource", &cosmosdb.SqlDatabaseArgs{
AccountName: pulumi.String("string"),
ResourceGroupName: pulumi.String("string"),
AutoscaleSettings: &cosmosdb.SqlDatabaseAutoscaleSettingsArgs{
MaxThroughput: pulumi.Int(0),
},
Name: pulumi.String("string"),
Throughput: pulumi.Int(0),
})
var sqlDatabaseResource = new SqlDatabase("sqlDatabaseResource", SqlDatabaseArgs.builder()
.accountName("string")
.resourceGroupName("string")
.autoscaleSettings(SqlDatabaseAutoscaleSettingsArgs.builder()
.maxThroughput(0)
.build())
.name("string")
.throughput(0)
.build());
sql_database_resource = azure.cosmosdb.SqlDatabase("sqlDatabaseResource",
account_name="string",
resource_group_name="string",
autoscale_settings={
"max_throughput": 0,
},
name="string",
throughput=0)
const sqlDatabaseResource = new azure.cosmosdb.SqlDatabase("sqlDatabaseResource", {
accountName: "string",
resourceGroupName: "string",
autoscaleSettings: {
maxThroughput: 0,
},
name: "string",
throughput: 0,
});
type: azure:cosmosdb:SqlDatabase
properties:
accountName: string
autoscaleSettings:
maxThroughput: 0
name: string
resourceGroupName: string
throughput: 0
SqlDatabase Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The SqlDatabase resource accepts the following input properties:
- Account
Name string - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- Autoscale
Settings SqlDatabase Autoscale Settings - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - Name string
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- Throughput int
- Account
Name string - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- Autoscale
Settings SqlDatabase Autoscale Settings Args - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - Name string
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- Throughput int
- account
Name String - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- autoscale
Settings SqlDatabase Autoscale Settings - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name String
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- throughput Integer
- account
Name string - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- resource
Group stringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- autoscale
Settings SqlDatabase Autoscale Settings - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name string
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- throughput number
- account_
name str - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- resource_
group_ strname - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- autoscale_
settings SqlDatabase Autoscale Settings Args - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name str
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- throughput int
- account
Name String - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- autoscale
Settings Property Map - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name String
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- throughput Number
Outputs
All input properties are implicitly available as output properties. Additionally, the SqlDatabase resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing SqlDatabase Resource
Get an existing SqlDatabase resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SqlDatabaseState, opts?: CustomResourceOptions): SqlDatabase@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
account_name: Optional[str] = None,
autoscale_settings: Optional[SqlDatabaseAutoscaleSettingsArgs] = None,
name: Optional[str] = None,
resource_group_name: Optional[str] = None,
throughput: Optional[int] = None) -> SqlDatabasefunc GetSqlDatabase(ctx *Context, name string, id IDInput, state *SqlDatabaseState, opts ...ResourceOption) (*SqlDatabase, error)public static SqlDatabase Get(string name, Input<string> id, SqlDatabaseState? state, CustomResourceOptions? opts = null)public static SqlDatabase get(String name, Output<String> id, SqlDatabaseState state, CustomResourceOptions options)resources: _: type: azure:cosmosdb:SqlDatabase get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Account
Name string - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- Autoscale
Settings SqlDatabase Autoscale Settings - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - Name string
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- Throughput int
- Account
Name string - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- Autoscale
Settings SqlDatabase Autoscale Settings Args - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - Name string
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- Resource
Group stringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- Throughput int
- account
Name String - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- autoscale
Settings SqlDatabase Autoscale Settings - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name String
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- throughput Integer
- account
Name string - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- autoscale
Settings SqlDatabase Autoscale Settings - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name string
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- resource
Group stringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- throughput number
- account_
name str - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- autoscale_
settings SqlDatabase Autoscale Settings Args - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name str
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- resource_
group_ strname - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- throughput int
- account
Name String - The name of the Cosmos DB SQL Database to create the table within. Changing this forces a new resource to be created.
- autoscale
Settings Property Map - An
autoscale_settingsblock as defined below. This must be set upon database creation otherwise it cannot be updated without a manual destroy-apply. - name String
- Specifies the name of the Cosmos DB SQL Database. Changing this forces a new resource to be created.
- resource
Group StringName - The name of the resource group in which the Cosmos DB SQL Database is created. Changing this forces a new resource to be created.
- throughput Number
Supporting Types
SqlDatabaseAutoscaleSettings, SqlDatabaseAutoscaleSettingsArgs
- Max
Throughput int - The maximum throughput of the SQL database (RU/s). Must be between
4,000and1,000,000. Must be set in increments of1,000. Conflicts withthroughput.
- Max
Throughput int - The maximum throughput of the SQL database (RU/s). Must be between
4,000and1,000,000. Must be set in increments of1,000. Conflicts withthroughput.
- max
Throughput Integer - The maximum throughput of the SQL database (RU/s). Must be between
4,000and1,000,000. Must be set in increments of1,000. Conflicts withthroughput.
- max
Throughput number - The maximum throughput of the SQL database (RU/s). Must be between
4,000and1,000,000. Must be set in increments of1,000. Conflicts withthroughput.
- max_
throughput int - The maximum throughput of the SQL database (RU/s). Must be between
4,000and1,000,000. Must be set in increments of1,000. Conflicts withthroughput.
- max
Throughput Number - The maximum throughput of the SQL database (RU/s). Must be between
4,000and1,000,000. Must be set in increments of1,000. Conflicts withthroughput.
Import
Cosmos SQL Database can be imported using the resource id, e.g.
$ pulumi import azure:cosmosdb/sqlDatabase:SqlDatabase db1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DocumentDB/databaseAccounts/account1/sqlDatabases/db1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
