Skip to content

Instantly share code, notes, and snippets.

@cdennig
Created October 3, 2021 15:49
Show Gist options
  • Save cdennig/368d2dc9359991e7a308de4a8f1e8d35 to your computer and use it in GitHub Desktop.
Save cdennig/368d2dc9359991e7a308de4a8f1e8d35 to your computer and use it in GitHub Desktop.
usage.cs
var credential = new DefaultAzureCredential();
var cosmosClient = new CosmosClient(_configuration["Cosmos:Uri"], credential);
var container = cosmosClient.GetContainer(_configuration["Cosmos:Db"], _configuration["Cosmos:Container"]);
var newId = Guid.NewGuid().ToString();
await container.CreateItemAsync(new {id = newId, partitionKey = newId, name = "Ted Lasso"},
new PartitionKey(newId), cancellationToken: stoppingToken);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment