Search code examples
azureindexingazure-cosmosdb

Cosmos DB indexing policy keepsreverting back to default after few hours into re-indexing


I am trying to update my Cosmos DB collection indexing policy but the new policy keeps reverting back to default policy (I had default policy set till now).

The new policy gets saved successfully and I can see re-indexing reaches 2-3% and then suddenly I see the policy reverting back to default and re-indexing starts again.

I have about 300GBs of data in my collection.

New indexing policy looks like this:

    {
        "indexingMode": "consistent",
        "automatic": true,
        "includedPaths": [
            {
                "path": "/someobj1/*"
            },
            {
                "path": "/someattr/?"
            },
            {
                "path": "/somearray/[]/*"
            },
            {
                "path": "/someattr/?"
            },
            {
                "path": "/someothrattr/?"
            },
            {
                "path": "/someoytherarr/[]/*"
            },
            {
                "path": "/someobj/anotherarr/[]/*"
            }
        ],
        "excludedPaths": [
            {
                "path": "/*"
            }
        ]
    }

AND it keeps reverting back to default policy:

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

Going to raise a support request for Azure as well as it could be a bug. Is anyone facing similar issue?


Solution

  • I faced the same situation and in my case I realized the indexing policy was reverted back to the default whenever the application was deployed. And the reason is that I am using ARM-Template to deploy Azure resources in the release pipeline where the indexing policy is not defined as part of cosmos container resource. So after adding the indexing policy in the ARM-Template using the guide (https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/manage-with-bicep), I dont loose the indexing policy anymore after each deployment.