Configure the project
It uses an Azure CosmosDB or InMemory database to store the example application data.
To interact with CosmosDb there is a environment variable that needs to be set. The InMemory database doesn't require additional configuration and upon project generation is the default option.
Using the Cosmos DB Emulator to run the database locally
For running on local environments, Cosmos DB emulator can be used in a Windows environment.
Install Cosmos DB Emulator
Identify the Primary key
Not using the Cosmos DB Emulator
Set the CosmosDB URI parameter DatabaseAccountUri
Create the Cosmos DB structure
Based on the solution template the Cosmos DB has to contain a fixed structure.
Create a collection Stacks with a container id menu (name of domain object) and the partition key /id.
For the project just created to connect to the Cosmos Db database, the primary key has to be provided as a environment variable. To add this variable perform one of the next two steps.
Setting the key as a system property
Replace the Cosmos DB Primary key in the command.
Run the command in powershell with administrator privileges.
Set the variable specific to Visual Studio
Open the project in Visual Studio. The solution file is located at
Add COSMOSDB_KEY environment variable to the launchSettings.json file generated by Visual Studio and add the Cosmos DB Primary key value.
The variable is referenced in appsettings.json.