title | description | author | ms.service | ms.subservice | ms.custom | ms.topic | ms.date | ms.author | ms.reviewer |
---|---|---|---|---|---|---|---|---|---|
Create and manage Azure Cosmos DB with Bicep |
Use Bicep to create and configure Azure Cosmos DB for API for NoSQL |
seesharprun |
azure-cosmos-db |
nosql |
devx-track-bicep |
how-to |
02/18/2022 |
sidandrews |
mjbrown |
[!INCLUDENoSQL]
In this article, you learn how to use Bicep to deploy and manage your Azure Cosmos DB accounts, databases, and containers.
This article shows Bicep samples for API for NoSQL accounts. You can also find Bicep samples for Cassandra, Gremlin, MongoDB, and Table APIs.
Important
- Account names are limited to 44 characters, all lowercase.
- To change the throughput (RU/s) values, redeploy the Bicep file with updated RU/s.
- When you add or remove locations to an Azure Cosmos DB account, you can't simultaneously modify other properties. These operations must be done separately.
- To provision throughput at the database level and share across all containers, apply the throughput values to the database options property.
To create any of the Azure Cosmos DB resources below, copy the following example into a new bicep file. You can optionally create a parameters file to use when deploying multiple instances of the same resource with different names and values. There are many ways to deploy Azure Bicep files including, Azure CLI, Azure PowerShell and Cloud Shell.
Create an Azure Cosmos DB account in two regions with options for consistency and failover, with database and container configured for autoscale throughput that has most index policy options enabled.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.documentdb/cosmosdb-sql-autoscale/main.bicep":::
Create an Azure Cosmos DB account in one region with a container with Analytical TTL enabled and options for manual or autoscale throughput.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.documentdb/cosmosdb-sql-analytical-store/main.bicep":::
Create an Azure Cosmos DB account in two regions with options for consistency and failover, with database and container configured for standard throughput that has most policy options enabled.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.documentdb/cosmosdb-sql/main.bicep":::
Create an Azure Cosmos DB account, database and container with a stored procedure, trigger, and user-defined function.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.documentdb/cosmosdb-sql-container-sprocs/main.bicep":::
Create an Azure Cosmos DB account, a natively maintained Role Definition, and a natively maintained Role Assignment for a Microsoft Entra identity.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.documentdb/cosmosdb-sql-rbac/main.bicep":::
Create a free-tier Azure Cosmos DB account and a database with shared throughput that can be shared with up to 25 containers.
:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.documentdb/cosmosdb-free/main.bicep":::
Here are some additional resources: