Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# cosmos db add items into container

using Microsoft.Azure.Cosmos

public class Test
{
	[JsonProperty(PropertyName = "CategoryId")]
	public int Id { get; set; }
}

public async Task AddItemsAsync(CosmosClient cosmosClient, Database database, Container container)
{

	Test test = new Test();
	test.Id = 0;

	ItemResponse<Test> testResponse = await container.CreateItemAsync<Test>(test, new PartitionKey("<Your partition key>"));

	Console.WriteLine("Created item in database with id: {0} Operation consumed {1} RUs.
"
		, testResponse.Resource.Id, testResponse.RequestCharge);
}
 
PREVIOUS NEXT
Tagged: #cosmos #db #add #items #container
ADD COMMENT
Topic
Name
1+1 =