问题
When deploying a Cosmos Db database in GlobalDocumentDB mode using the Azure resource manager template there is no way to configure collections in the database during deployment that I can tell.
During a ARM template deployment is there any way to either (in order of preference)
- Configure the collections in a Cosmos Db database directly in a way that I have overlooked.
- Do a series of REST requests from within the template to configure the db.
- Do a single REST request within the template to hit a Azure Function with a HttpTrigger that will configure the database.
回答1:
You should be able to use these Templates.
- Containers:
https://docs.microsoft.com/en-us/azure/templates/microsoft.documentdb/2015-04-08/databaseaccounts/apis/databases/containers - Collections:
https://docs.microsoft.com/en-us/azure/templates/microsoft.documentdb/2015-04-08/databaseaccounts/apis/databases/collections - All Microsoft.DocumentDB Resource Types:
https://docs.microsoft.com/en-us/azure/templates/microsoft.documentdb/allversions
These pages were published on 05/01/2019 & are for API version 2015-04-08.
回答2:
ARM templates is used to create Azure resources, there is no way to configure collection during deploy ARM template. To configure collections, I suggest you use REST API. Before creating a collection, we need to create a database first. Following are documents which show us how to create DocumentDB databases and collections.
Create Database
Create Collection
来源:https://stackoverflow.com/questions/46223053/how-to-configure-a-cosmos-db-collection-during-deployment