4ybaka
4ybaka

Reputation: 3264

ARM template for composite index in DocumentDB

There are multiple ways how to create composite index. But I see no ARM templates there and latest scheme for containers also has no it. When we can use ARM templates to define composite indexes?

Upvotes: 0

Views: 165

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136226

Can you try something like the following:

{
  "name": "string",
  "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
  "apiVersion": "2020-03-01",
  "location": "string",
  "tags": {},
  "properties": {
    "resource": {
      "id": "string",
      "indexingPolicy": {
        "automatic": "boolean",
        "indexingMode": "string",
        "includedPaths": [
          {
            "path": "string",
            "indexes": [
              {
                "dataType": "string",
                "precision": "integer",
                "kind": "string"
              }
            ]
          }
        ],
        "excludedPaths": [
          {
            "path": "string"
          }
        ],
        "spatialIndexes": [
          {
            "path": "string",
            "types": [
              "string"
            ]
          }
        ],
        "compositeIndexes":[  
            [  
                {  
                    "path":"/name",
                    "order":"ascending"
                },
                {  
                    "path":"/age",
                    "order":"descending"
                }
            ]
        ]
      },
      "partitionKey": {
        "paths": [
          "string"
        ],
        "kind": "string",
        "version": "integer"
      },
      "defaultTtl": "integer",
      "uniqueKeyPolicy": {
        "uniqueKeys": [
          {
            "paths": [
              "string"
            ]
          }
        ]
      },
      "conflictResolutionPolicy": {
        "mode": "string",
        "conflictResolutionPath": "string",
        "conflictResolutionProcedure": "string"
      }
    },
    "options": {
      "additionalProperties": {},
      "throughput": "string"
    }
  },
  "resources": []
}

I simply took the template definition from here and added definition for composite index from here under indexing policy section.

Upvotes: 1

Related Questions