azure - 为什么 CosmosDB 在通过 ARM 模板创建文档集合时忽略索引?

标签 azure azure-cosmosdb azure-resource-manager

给定 ARM 模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "name": "1test2/sql/2test3/3test4",
      "type": "Microsoft.DocumentDB/databaseAccounts/apis/databases/containers",
      "apiVersion": "2015-04-08",
      "properties": {
        "resource": {
          "id": "3test4",
          "indexingPolicy": {
            "indexingMode": "Consistent",
            "includedPaths": [
              {
                  "path": "/definition/property/?",
                  "indexes": [
                    {
                        "kind": "Range",
                        "dataType": "String"
                    }
                ]
              }
          ],
            "excludedPaths": [
            {
                "path": "/*"
            }
        ]
          },
          "partitionKey": {
            "paths": [
              "/definition/id"
            ],
            "kind": "Hash"
          },
        },
        "options": {}
      }
    }
  ]
}

使用 PowerShell 命令部署到现有 CosmosDB 数据库时 New-AzureRmResourceGroupDeployment,生成的索引设置为:

{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [
        {
            "path": "/definition/property/?",
            "indexes": []
        }
    ],
    "excludedPaths": [
        {
            "path": "/*"
        },
        {
            "path": "/\"_etag\"/?"
        }
    ]
}

因此,虽然 CosmosDB 接受“includedPaths”,但它会忽略“索引”。我做错了什么还是这是预期的?

最佳答案

最近对 Cosmos DB 索引引擎进行了更改,默认为字符串和数字的范围索引,精度为 -1。

ARM 模板和文档尚未更新以反射(reflect)此默认值。

如果对索引策略进行非默认更改(例如添加空间索引),它们将包含在已部署的容器中。

关于azure - 为什么 CosmosDB 在通过 ARM 模板创建文档集合时忽略索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56890277/

相关文章:

Azure 资源管理器 API - 列出不包括属性的资源

c# - 使用自定义模型通过 C# 中的 Forms Recognizer V3 nuget 从表中提取数据

ARM 模板部署中缺少 Azure Web App 暂存槽应用程序设置

Azure AD 应用程序角色授权 : Tenant Admin Delegation

azure-cosmosdb - 局域网上的 Azure Cosmos DB 模拟器

Azure Cosmos db 集合上的唯一键

node.js - 如何使用 Cosmos DB 触发器构建 Azure 函数?

ruby - 从托管镜像创建虚拟机

c# - Application Insights 不包括自定义 ITelemetryInitializer 设置的属性

c# - Azure函数中通过实例id获取主机锁租约的原因是什么?