azure-docs
azure-docs copied to clipboard
Code sample not working in Azure CosmosDB with Gremlin
Code does not work in Azure CosmosDB, partition key is always needed when creating vertices.
g.addV('person').
property('id', 'thomas.1').
property('firstName', 'Thomas').
property('lastName', 'Andersen').
property('age', 44)
as stated in the documentation does not run successfully.
Error message from Azure:
Failure in submitting query: g.addV('person'). property('id', 'thomas.1'). property('firstName', 'Thomas'). property('lastName', 'Andersen'). property('age', 44): Script eval error: ActivityId : 11d3e271-6f6b-4999-ab30-0f1d5a1be41b ExceptionType : GraphRuntimeException ExceptionMessage : Gremlin Query Execution Error: Cannot add a vertex where the partition key property has value 'null'. GremlinRequestId : e4f842f2-c18c-4dc5-bcf4-34f436e20bf7 Context : graphcompute Scope : graphcomp-execquery GraphInterOpStatusCode : GraphRuntimeError HResult : 0x80131500
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: cef3a243-cafc-7f37-6b8c-0ef8e7f1eb15
- Version Independent ID: 4ce9b0b3-d701-c516-3bcf-f8ffd18d95ed
- Content: Introduction - Azure Cosmos DB for Apache Gremlin
- Content Source: articles/cosmos-db/gremlin/introduction.md
- Service: cosmos-db
- Sub-service: apache-gremlin
- GitHub Login: @manishmsfte
- Microsoft Alias: mansha
@kedzilla Thanks for your findings, I'm assigning this to the author for the feedback review.
@kedzilla, after reading through this article, I'm not sure if it recommends a partition key for this code sample.
I created a graph and used /lastName
as the partition key and things worked fine.
What partition key did you use?
@kedzilla, we will update the article to indicate that you can use lastName
as a partition key if you're following along with the samples.
Essentially, in each vertex you add to the graph, you need a property that has the graph's partition key.
Example:
-
Create a Graph with a partition key
/location
, then -
Create a vertex with property "location":
g.addV("users").property("location", "united kingdom").property("name", "jackson").property("age", "30")