将 cosmosdb 从手动切换到自动缩放

时间:2021-03-31 14:16:38

标签: azure-cosmosdb autoscaling arm-template throughput

是否可以使用 ARM 模板将 cosmosdb 容器从手动切换到自动缩放?

我正在尝试通过跟随 arm 来实现这一点,但我仍然将 TU 设置设置为手动

{
  "name": "db/collection/container/default",
  "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/throughputSettings",
  "apiVersion": "2020-03-01",
  "properties": {
    "resource": {
      "throughput": "4000",
      "autoscaleSettings": {
        "maxThroughput": "800000"
      }
    }
  },

1 个答案:

答案 0 :(得分:2)

无法执行此操作,因为此调用是对 Cosmos DB 资源提供程序的 POST。

从标准吞吐量迁移到自动缩放吞吐量的唯一方法是使用 Azure 门户、PowerShell 或 Azure CLI。然后,您可以修改您的 ARM 模板并通过在资源选项中使用适当的吞吐量 json 重新部署模板来更新吞吐量量。

这是从标准到自动缩放的容器的 PS 示例。

Invoke-AzCosmosDBSqlContainerThroughputMigration `
   -ResourceGroupName $resourceGroupName `
   -AccountName $accountName `
   -DatabaseName $databaseName `
   -Name $containerName `
   -ThroughputType Autoscale

更多PowerShell examples

这是一个容器从标准到自动缩放的 cli 示例

az cosmosdb sql container throughput migrate \
-a $accountName \
-g $resourceGroupName \
-d $databaseName \
-n $containerName \
-t 'autoscale'

更多CLI examples

如果对其他数据库 API 执行此操作,请在文档中找到 PS 或 CLI 示例。有适用于所有数据库 API 的示例。