【问题标题】:Is it possible to provision throughput on Database level through code or arm template using Table API in cosmos db?是否可以使用 cosmos db 中的 Table API 通过代码或 arm 模板在数据库级别提供吞吐量?
【发布时间】:2019-06-26 11:56:42
【问题描述】:

我正在尝试在 Azure DevOps 中设置发布管道,以使用 Azure 资源管理器模板部署 Azure 环境。我要创建的资源之一是使用 Azure Table Api 的 Cosmos DB 实例,我想为整个数据库而不是 pr 预配“帐户级别吞吐量”。桌子。我可以通过 ARM 模板使用正确的 api 创建 Cosmos DB 实例,但我无法通过模板或使用 Microsoft.Azure.Cosmos.Table api 将“帐户级别吞吐量”设置为“开启” .

我能够进行配置的唯一方法是登录 Azure 门户并手动进行。是否可以通过 ARM 模板或使用 Powershell 或 Microsoft.Azure.Cosmos.Table api 自动执行此操作?

这是我目前使用的模板

{
      "type": "Microsoft.DocumentDB/databaseAccounts",
      "name": "[variables('cosmosStreamDBName')]",
      "apiVersion": "2016-03-31",
      "location": "[parameters('location')]",
      "tags": {
        "defaultExperience": "Azure Table"
      },
      "kind": "GlobalDocumentDB",
      "properties": {
        "capabilities": [ { "name": "EnableTable" } ],
        "consistencyPolicy": {
          "defaultConsistencyLevel": "BoundedStaleness",
          "maxIntervalInSeconds": 86400,
          "maxStalenessPrefix": 1000000
        },
        "databaseAccountOfferType": "Standard",
        "enableAutomaticFailover": false,
        "enableMultipleWriteLocations": false,
        "isVirtualNetworkFilterEnabled": false,
        "virtualNetworkRules": [],
        "locations": [
          {
            "locationName": "[parameters('location')]",
            "failoverPriority": 0
          }
        ]
      }
    }

这是一个示例,说明我在使用 SQL api 时如何在数据库级别配置吞吐量:

var client = new DocumentClient(
   new Uri(EndpointUri), 
   PrimaryKey, 
   serializerSettings: Settings
);

var db =  await client.CreateDatabaseIfNotExistsAsync(
   new Database { Id = DatabaseName }, 
   new RequestOptions() { 
     PartitionKey = new PartitionKey(key), 
     OfferThroughput = 400 
   }
);

【问题讨论】:

    标签: azure azure-cosmosdb


    【解决方案1】:

    现在有可能: 见https://github.com/Azure/azure-quickstart-templates/blob/master/101-cosmosdb-sql/azuredeploy.json

        {
            "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
            "name": "[concat(variables('accountName'), '/', parameters('databaseName'))]",
            "apiVersion": "2019-08-01",
            "dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('accountName'))]" ],
            "properties":{
                "resource":{
                    "id": "[parameters('databaseName')]"
                },
                "options": { "throughput": "[parameters('sharedThroughput')]" }
            }
        },
    

    【讨论】:

    【解决方案2】:

    试试下面的手臂模板:

    {
        "type": "Microsoft.DocumentDB/databaseAccounts/apis/tables",
        "name": "[concat(account-name, '/table/', database-name)]",
        "apiVersion": "2016-03-31",
        "dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/', account-name)]" ],
        "properties":{
            "resource":{
                "id": "table-name"
            },
            "options": {
                "x-ms-offer-throughput": 1000
            }
        }
    }
    

    参考:
    https://docs.microsoft.com/en-us/rest/api/cosmos-db/create-a-collection
    https://docs.microsoft.com/en-us/rest/api/cosmos-db-resource-provider/databaseaccounts/createupdatetable

    ps。不确定x-ms-offer-throughput,可能只是throughput

    【讨论】:

    • 感谢您的回答,但如果您想在 Cosmos 数据库中的表上设置吞吐量,此模板可以正常工作。我想要实现的是设置数据库中所有表共享的“帐户级别吞吐量”。必须在创建任何表之前设置“帐户级别吞吐量”。我尝试在数据库帐户模板上使用x-ms-offer-throughputthroughput 选项,但这不起作用。
    【解决方案3】:

    请参阅下面的 ARM 模板,为 Cosmos 表提供吞吐量并稍后更新该吞吐量。

    此 arm 模板创建一个带有初始吞吐量集的 Cosmos 表。 https://azure.microsoft.com/en-us/resources/templates/101-cosmosdb-table/

    此模板更新现有表的吞吐量。 https://azure.microsoft.com/en-us/resources/templates/101-cosmosdb-table-ru-update/

    我们目前正在努力让客户重新部署用于配置帐户和表资源的相同模板,以更新吞吐量。这应该会在 10 月或 11 月初推出。

    谢谢。

    【讨论】:

      【解决方案4】:

      我在 Twitter 上询问了 Cosmos DB 团队并得到了这个答案:

      “从今天开始,这只能通过门户获得。请随时将此作为建议添加到我们的用户语音中,以便我们可以在下一个计划周期中查看它,https://feedback.azure.com/forums/263030-azure-cosmos-db?category_id=321997

      https://twitter.com/AzureCosmosDB/status/1175071433229312001

      希望他们能在稍后阶段实现这一点。

      我为 Cosmos DB 团队创建了一个您可以投票的建议:https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/38682238-set-account-level-throughput-on-cosmos-db-table-ap

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-08-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-07-22
        • 1970-01-01
        相关资源
        最近更新 更多