Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure CosmosDB: illegal characters in Document Id

I have the issue that the Ids that are being generated based on certain input contain the character "/". This leads to an error during the Upsert operation as "/" is not allowed in the Document id.

Which characters are not allowed beside that? What are ways to handle such a situation?

like image 954
quervernetzt Avatar asked Oct 17 '25 10:10

quervernetzt


1 Answers

The illegal characters are /, \\, ?, # (see https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.documents.resource.id?view=azure-dotnet)

Ways to deal with such a situation:

  • Remove the character already in the input used for generating the id
  • Replace the character in the id with another character / set of characters
  • Use Hashing / Encoding (e.g. Base64)

If you know a better way please share. Thanks

like image 159
quervernetzt Avatar answered Oct 20 '25 13:10

quervernetzt