Azure Cosmos DB for NoSQL client library samples for .NET
Getting started
This repo has a devcontainer environment making it easy to get started.
Run the app
Configure your Azure Cosmos DB credentials as environment variables.
export COSMOS_ENDPOINT="<cosmos-account-URI>"
export COSMOS_KEY="<cosmos-account-PRIMARY-KEY>"
đź’ˇ TIP: If you don't have an Azure Cosmos DB account, create a free account.
Run the quickstart sample app using the Microsoft.Azure.Cosmos package from NuGet.
cd 001-quickstart/
dotnet add package Microsoft.Azure.Cosmos
dotnet run
Validate any changes you make
If you change the code, run the formatter and test the build.
dotnet format
dotnet build
Troubleshooting certificate errors
If you use a self-signed certificate, you may need to disable the client's validation:
CosmosClientOptions options = new ()
{
HttpClientFactory = () => new HttpClient(new HttpClientHandler()
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
}),
ConnectionMode = ConnectionMode.Gateway
};
>
using CosmosClient client = new(
...,
...,
clientOptions: options
);