Search code examples
azure-cosmosdb

Is there another solution for deprecated UriFactory.CreateDocumentUri in cosmosDb?


I am using UpsertItemAsync to create a document and I need to get the uri to that created document, is there some replacement for deprecated CreateDocumentUri or I have to do it manually?


Solution

  • CreateDocumentUri just does a string concatenation of the Database Name, Container Name, and item Id.

    CreateDocumentUri was used to execute the operation in V2 because the original input for the V2 SDK was not using the names, and when naming was introduced 5+ years ago, this API was added to make things easier.

    In V3, the naming is implicitly a part of the APIs themselves and this method is not needed.

    The names of the Database, Container, and the item Id are things you probably already have available when you are calling UpsertItemAsync.