Search code examples
azureazure-cosmosdbazure-resource-managerazure-cosmosdb-sqlapi

ARM template throws "Shared throughput collection should have a partition key"


I am trying to create a cosmosdb account with shared throughput, I have the partition key mentioned in the ARM, but it doesn’t seem to take this when creating container.

"properties": {
        "resource": {
          "id": "[variables('cosmosDbContainers')[copyIndex()]]"
        },
        "partitionKey": {
          "paths": [
            "/id"
          ],
          "kind": "Hash"
        },
        "indexingPolicy": {
          "indexingMode": "consistent",
          "automatic": true,
          "includedPaths": [
            {
              "path": "/*"
            }
          ],
          "excludedPaths": [
            {
              "path": "/\"_etag\"/?"
            }
          ]
        },

Solution

  • Looks like the placement of partitionKey in the ARM is wrong, it should be under the "resource" key

     "resource": {
                "id": "[variables('cosmosDbContainers')[copyIndex()]]",
                "partitionKey": {
                    "paths": [
                        "/ipCountryCode"
                    ],
                    "kind": "Hash"
                }
            },