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
    }
  ]
}
1

There are 1 best solutions below

1
On

If any of the collections in the target account inside the provided database do not exist, the error message will appear.

  • Make sure the Connection String points to the correct account and that the collections are visible in the database
  • For this, with your connection string you can browse Cosmos Explorer you can use the Azure Portal,

A Firewall rule (either Virtual Network or IP rules) of your account prevents access to your current workstation.

  • Check the Account to see if there is a rule preventing your access. You can either disable or add your current IP address to the Firewall rule.