Share via

Cannot create leases container (Gremlin API) with /id as partition key, but comos db trigger requires /id as partition key

Sheoran, Tanmay 1 Reputation point
2022-04-29T08:14:15.947+00:00

I am trying to create a cosmos db trigger for Gremlin API, since the trigger requires partition key as /id, I am not able to create it either from settings in trigger itself (createLeaseCollectionIfNotExists) nor from the azure portal, since it partition key cannot be either /id or /label.

is there any work around for the same, either creating a timer trigger using change feed to look for partition key I have specified in Gremplin API containers or any configuration changes in the api/containter itself

Error Message:
The 'CosmosTrigger' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.CosmosTrigger'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create Collection Information for Contacts in database GraphDB with lease leases in database GraphDB : Partition key path /id is invalid for Gremlin API. The path cannot be '/id', '/label' or a nested path such as '/key/path'

function.json:
{
"scriptFile": "init.py",
"bindings": [
{
"type": "cosmosDBTrigger",
"name": "documents",
"direction": "in",
"leaseCollectionName": "leases",
"connectionStringSetting": "DOCUMENTDB",
"databaseName": "GraphDB",
"collectionName": "Contacts",
"createLeaseCollectionIfNotExists": true
}
]
}

Azure Cosmos DB
Azure Cosmos DB

An Azure NoSQL database service for app development.


1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,597 Reputation points Microsoft Employee Moderator
    2022-05-03T21:27:17.407+00:00

    Hi @Sheoran, Tanmay Unfortunately this feature is not supported.
    As a workaround, you can use a separate CosmosDB SQL API account to store the lease containers.

    See https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-trigger?tabs=in-process%2Cfunctionsv2&pivots=programming-language-javascript#connection-string

    Specifically leaseConnectionStringSetting - to specify a separate account to use.

    Please let me know if you need any additional information.

    Regards
    Geetha

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.