How to configure a Cosmos Db collection during deployment

烈酒焚心 提交于 2019-12-08 17:36:07

问题


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)

  1. Configure the collections in a Cosmos Db database directly in a way that I have overlooked.
  2. Do a series of REST requests from within the template to configure the db.
  3. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!