Home
Softono

Cosmos Db Nosql Dotnet Samples

Open source MIT C#
43
Stars
46
Forks
1
Issues
25
Watchers
2 years
Last Commit

 About Cosmos Db Nosql Dotnet Samples

Sample .NET applications for Azure Cosmos DB for NoSQL

Platforms

Web Self-hosted Windows

Languages

C#

Need Help Installing Cosmos Db Nosql Dotnet Samples?

We provide expert installation service for this software. Our team will install, configure, and secure Cosmos Db Nosql Dotnet Samples on your server. plans start at just $30.

Cosmos Db Nosql Dotnet Samples

View on GitHub

Azure Cosmos DB for NoSQL client library samples for .NET

Validate .NET code samples

Getting started

This repo has a devcontainer environment making it easy to get started.

Open in GitHub Codespaces

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
);