AZ
Azure-Samples/cosmos-db-nosql-dotnet-samples
Sample .NET applications for Azure Cosmos DB for NoSQL
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 runValidate any changes you make
If you change the code, run the formatter and test the build.
dotnet format
dotnet buildTroubleshooting 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
);