How to create a container with the specific parameters in Azure cosmosdb

I am trying to create a container in my testdatabase (Azure cosomosdb) with the following parameters. using python.However i am get the below error and failing to create the container. Would you please help to correct me if i am doing something wrong.

location_container_name = "locations"
try:
    container = database.create_container(
        id=location_container_name, partition_key=PartitionKey(path=["/state", "/city", "/zipcode"], kind="MultiHash")
    )
except exceptions.CosmosResourceExistsError:
    container = database.get_container_client(container_name)

Error details:-

azure.cosmos.exceptions.CosmosHttpResponseError: (BadRequest) The specified document collection is invalid.
ActivityId: b0e78b5f-abe8-479e-9005-606370644a78, Microsoft.Azure.Documents.Common/2.14.0
Code: BadRequest
Message: The specified document collection is invalid.
ActivityId: b0e78b5f-abe8-479e-9005-606370644a78, Microsoft.Azure.Documents.Common/2.14.0

expecting the output as below:-

I need the container with the name “locations” and with the path as below.

id      /state    /city    /zipcode

item1   WA      Redmond    98052

Leave a Comment