azure-cosmosdbazure-ai-search

Azure AI Search - Container name is invalid for type cosmosdb


I am trying to create a datasource pointing to a cosmosdb container in an azure ai search service, but I always get the error Container name xxx is invalid for type cosmosdb. The cosmodb container is named "suppliers_clients_projections".

I tried using the REST API and the Azure Portal but same error in both case.

REST Api request example:

POST https://[service name].search.windows.net/datasources?api-version=2024-07-01
    Content-Type: application/json  
    api-key: [admin key]  
{
        "name": "<my-datasource-name>",
        "container": {
            "name": "suppliers_clients_projections",
            "query": "select c.id, c.name, c.isDeleted, c._ts FROM c WHERE c._ts >= 
 @HighWaterMark ORDER BY c._ts"
        },
        "type": "cosmosdb",
        "credentials": {
            "connectionString": "<my-cosmosdb-cs>"
        },
        "dataChangeDetectionPolicy": {
            "@odata.type": "#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy",
            "highWaterMarkColumnName": "_ts"
        },
        "dataDeletionDetectionPolicy": {
            "@odata.type": "#Microsoft.Azure.Search.SoftDeleteColumnDeletionDetectionPolicy",
            "softDeleteColumnName": "isDeleted",
            "softDeleteMarkerValue": "true"
        }
    }

Oddly, using the same method I succeeded to create a datasource for a container named "products". What could be wrong with the first container ?


Solution

  • Agreed with the @amit_g, I also reproduced the issue with the collection when name contain whitespaces and underscore it throwed the error but for hyphen ( - ) it worked so the naming convention is like Letters, numbers, dashes ( - ).

    It might a limitation in Azure AI search but for more further support you can raise support request to Microsoft here.

    If its limitation you need to change the name of the container in cosmos db. but unfortunately renaming container is not possible you need to recreate the container with another name and add items in it for this, you can use other azure services like Azure data factory here you can use Copy activity to transfer all the items from one container to another.