Get started with the Azure Cosmos DB SQL API client library for .NET. Follow the steps in this document to install the .NET package, create an application, and try out sample code for basic CRUD operations on data stored in Azure Cosmos DB.
Azure Cosmos DB is Microsoft's fast NoSQL afghanistan mobile database with open APIs for any scale. You can use Azure Cosmos DB to quickly create and query key/value, document, and graph databases. Use the Azure Cosmos DB SQL API client library for .NET to:
Create an Azure Cosmos DB and Container
Add sample data to the container
Consult the data
Delete the database
API Reference Documentation | Library Source Code | Package (NuGet)
Prerequisites
Azure Subscription – Create one for free or you can Try Azure Cosmos DB for free without an Azure subscription, no charge and no commitment.
.NET Core SDK 2.1 or later .
Setting up
This section walks you through creating an Azure Cosmos account and configuring a project that uses the Azure Cosmos DB SQL API client library for .NET to manage resources. The sample code described in this article creates the database FamilyDatabase and family members (each family member is an item) within that database. Each family member has properties such as Id, FamilyName, FirstName, LastName, Parents, Children, Address,. The property LastName is used as the partition key for the container.
Create an Azure Cosmos account
If you use the Try Azure Cosmos DB for free option to create an Azure Cosmos account, you must create an Azure Cosmos DB account of type SQL API . An Azure Cosmos DB test account has already been created for you. You don't need to create the account explicitly, so you can skip this section and move on to the next one.
If you have your own Azure subscription or created one for free, you must explicitly create an Azure Cosmos account. The following code will create an Azure Cosmos account with session consistency. The account is replicated to South Central US and from North Central US.
You can use Azure Cloud Shell to create your Azure Cosmos account. Azure Cloud Shell is an interactive, authenticated, browser-accessible shell for managing Azure resources. It gives you the flexibility to choose the shell experience that best suits how you work, whether you use Bash or PowerShell. For this quickstart, choose Bash mode . Azure Cloud Shell also requires a storage account, which you can create when prompted.
How to create an Azure Cosmos DB .NET console application
-
- Posts: 854
- Joined: Mon Dec 23, 2024 3:33 am