update cosmos db document with new values c#

class Program
static void Main(string[] args)


private static async Task NewMethod()
var client = new DocumentClient(new Uri(“uri”), “key”);

//Fetch the Document to be updated
var doc = client.CreateDocumentQuery<RootObject>(UriFactory.CreateDocumentCollectionUri(“Db-dev”, “collection”))
.Where(t => t.id == “id”).AsEnumerable()

List<string> ok = new List<string>() { “d1”, “d2” };

//update document

var result = client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(“Db-dev”, “collection”, “id”), doc).Result.Resource;


catch (Exception ex)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s