Azure Cosmos DB
An Azure NoSQL database service for app development.
1,901 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to connect and save/retrieve data to Azure Cosmos DB. I have referred to the Azure Documentation but am still
having difficulties. I am using Windows 10 and using the following code snippet. Please provide any help!
@Gerardo Canio Please share your code snippet to better assist you or here is the sample code Azure Cosmos DB using the NoSQL API and perform basic data operations which can try and don't forget to replace with your cosmos DB connection string.
using System;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
class Program
{
private static readonly string connectionString = "your_cosmosdb_connection_string";
private static readonly string databaseId = "your_database_name";
private static readonly string containerId = "your_container_name";
static async Task Main(string[] args)
{
CosmosClient cosmosClient = new CosmosClient(connectionString);
Database database = await cosmosClient.CreateDatabaseIfNotExistsAsync(databaseId);
Container container = await database.CreateContainerIfNotExistsAsync(containerId, "/partitionKey");
// Rest of the code remains the same as in the previous example
// ...
}
}
Regards
Geetha