I am trying to upgrade my project from DocumentDbClient
to CosmosClient
. In the existing code I have client methods like: CreateDocumentAsync(), CreateDocumentQuery(), and UpsertDocumentAsync()
available but when updating the client to CosmosClient
, I don’t have any of the methods available. What is the easiest way to do this migration and what alternative do I have for these method in the new CosmosClient
. Here’s an existing sample method using the DocumentDbClient
that I want to migrate and use CosmosClient
instead:
private async Task<ResourceResponse<Document>> UpsertStoreItemToDocumentDb(
Uri collectionUri,
TSt storeType,
RequestContext requestContext)
{
var client = await GetClient(requestContext);
return await client.UpsertDocumentAsync(collectionUri, storeType)
.TrackDiagnosticData(
sourceName: () => ApiProviderSettings.Name,
actionName: () => $"Upsert-{SourceMapping.ResourceDescription.Name}");
}
I do see using client.GetContainer()
and then doing createItemAsync
and UpsertItemAsync
but before going that route just want to know if anyone has done this before what is the easy way to do this. Thanks!