Simple step by step implementation of Cosmos DB with SQL Api in Dotnet core application. Official explanation could be find here.
a. Subscription: Free Trial
b. Resource group: FreeStorageDemo
c. API: Core SQL
d. Account Name: cosmossqlapi
After successful creation of storage, get Keys:
a. URI
b. PRIMARY KEY
c. SECONDARY KEY
d. PRIMARY CONNECTION STRING
e. SECONDARY CONNECTION STRING
Either we can create Database manually through portal, or can use programming language. Here I am creating a simple dotnet core web api which will automatically create database and its containers with partition. Codebase for Cosmos db implementation with dotnet core api is available here on GitHub.
I have added Nuget package "Microsoft.Azure.Cosmos"
After running the endpoint in demo app, we can verified that Collection has been created under database in Azure portal
And also verified that collection contains items.
- https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-dotnet-application
- https://docs.microsoft.com/en-us/azure/cosmos-db/sql-query-getting-started
a. Subscription: Free Trial
b. Resource group: FreeStorageDemo
c. API: Core SQL
d. Account Name: cosmossqlapi
After successful creation of storage, get Keys:
a. URI
b. PRIMARY KEY
c. SECONDARY KEY
d. PRIMARY CONNECTION STRING
e. SECONDARY CONNECTION STRING
Mainly we will be using a and b in our case.
Either we can create Database manually through portal, or can use programming language. Here I am creating a simple dotnet core web api which will automatically create database and its containers with partition. Codebase for Cosmos db implementation with dotnet core api is available here on GitHub.
I have added Nuget package "Microsoft.Azure.Cosmos"
After running the endpoint in demo app, we can verified that Collection has been created under database in Azure portal
And also verified that collection contains items.
Further we could fetch
data by using API.