This repo has a devcontainer environment making it easy to get started.
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
If you change the code, run the formatter and test the build.
dotnet format
dotnet build
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
);