This is a sample using Azure/azure-cosmos-dotnet-v3 SDK.
This library need following appsettings.json.
(The following values are sample values)
{
"cosmosOptions": {
"currentRegion": "",
"databaseId": "SampleDb",
"defaultThroughput": 400,
"needCreateIfExist": false,
"throttlingRetryOptions": {
"maxRetryWaitTimeInSeconds": 1,
"numberOfRetries": 3
},
"cosmosContainerOptions": [
{
"containerId": "items",
"partitionKey": "/division",
"uniqueKeys": [ "/companyId", "/employeeId" ]
}
]
},
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
}
if you use Azure Cosmos DB Emulator in local debug,
set connectionString to cosmosDbConnectionString
section in local.settings.json.
And On Azure Functions, set connectionString to cosmosDbConnectionString
key on ApplicationSettings.
if you use Azure Cosmos DB Emulator in local debug,
set connectionString to cosmosDbConnectionString
section in appsettings.Development.json .
On Azure, should set connectionString to cosmosDbConnectionString
key on ApplicationSettings.
When using ASP.NET Core, the environment name is set by default.
if use ConsoleApp, you need to set environment name value.
please watch ConsoleAppSample project > Program.cs > ConfigureHostConfiguration
section.
⚠️ Using Azure Functions V2, If useenv.EnvironmentName
, need to set environment variables by "AZURE_FUNCTIONS_ENVIRONMENT" key. (TargetFramework: netcoreapp2.2)
Please see Startup.cs
in FunctionsV2Sample project.
Please see Startup.cs
and CarRepository.cs
in AspnetCoreSample project.
Please see ConsoleAppSample project. This is Generic Host sample.