2021-05-06 00:57:41 +03:00
[![NuGet ](https://img.shields.io/nuget/v/Microsoft.Azure.Cosmos.svg )](https://www.nuget.org/packages/Microsoft.Azure.Cosmos)
[![NuGet Prerelease ](https://img.shields.io/nuget/vpre/Microsoft.Azure.Cosmos.svg )](https://www.nuget.org/packages/Microsoft.Azure.Cosmos)
2019-08-06 19:03:53 +03:00
2019-07-30 19:53:03 +03:00
# Microsoft Azure Cosmos DB .NET SDK Version 3
2019-02-13 23:40:19 +03:00
2023-04-04 17:50:11 +03:00
This client library enables client applications to connect to Azure Cosmos DB for NoSQL. Azure Cosmos DB is a globally distributed, multi-model database service. For more information, refer to https://azure.microsoft.com/services/cosmos-db/.
2019-07-17 16:48:30 +03:00
```csharp
CosmosClient client = new CosmosClient("https://mycosmosaccount.documents.azure.com:443/", "mysupersecretkey");
Database database = await client.CreateDatabaseIfNotExistsAsync("MyDatabaseName");
Container container = await database.CreateContainerIfNotExistsAsync(
"MyContainerName",
"/partitionKeyPath",
400);
2020-01-07 22:04:22 +03:00
// Create an item
dynamic testItem = new { id = "MyTestItemId", partitionKeyPath = "MyTestPkValue", details = "it's working", status = "done" };
2020-01-24 09:30:21 +03:00
ItemResponse< dynamic > createResponse = await container.CreateItemAsync(testItem);
2020-01-07 22:04:22 +03:00
// Query for an item
2022-10-07 22:07:53 +03:00
using (FeedIterator< dynamic > feedIterator = container.GetItemQueryIterator< dynamic > (
2020-06-18 22:41:33 +03:00
"select * from T where T.status = 'done'"))
2020-01-07 22:04:22 +03:00
{
2020-06-18 22:41:33 +03:00
while (feedIterator.HasMoreResults)
2020-01-07 22:04:22 +03:00
{
2020-06-18 22:41:33 +03:00
FeedResponse< dynamic > response = await feedIterator.ReadNextAsync();
foreach (var item in response)
{
Console.WriteLine(item);
}
2020-01-07 22:04:22 +03:00
}
}
2019-07-17 16:48:30 +03:00
```
2019-02-13 23:40:19 +03:00
2019-07-17 16:48:30 +03:00
## Install via [Nuget.org](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/)
2019-02-13 23:40:19 +03:00
2019-07-17 16:48:30 +03:00
`Install-Package Microsoft.Azure.Cosmos`
2019-02-13 23:40:19 +03:00
2023-11-22 01:00:40 +03:00
For available versions, see [SDK versioning ](./docs/versioning.md ).
2019-07-17 16:48:30 +03:00
## Useful links
2019-02-13 23:40:19 +03:00
2019-07-17 16:48:30 +03:00
- [Get Started APP ](https://docs.microsoft.com/azure/cosmos-db/sql-api-get-started )
2020-02-06 18:26:35 +03:00
- [GitHub samples ](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples )
2021-10-12 04:44:52 +03:00
- [SDK Best practices ](https://docs.microsoft.com/azure/cosmos-db/sql/best-practice-dotnet )
2019-07-17 16:48:30 +03:00
- [MultiMaster samples ](https://github.com/markjbrown/azure-cosmosdb-dotnet/tree/master/samples/MultiMaster )
- [Resource Model of Azure Cosmos DB Service ](https://docs.microsoft.com/azure/cosmos-db/sql-api-resources )
- [Cosmos DB Resource URI ](https://docs.microsoft.com/rest/api/documentdb/documentdb-resource-uri-syntax-for-rest )
- [Partitioning ](https://docs.microsoft.com/azure/cosmos-db/partition-data )
2023-04-04 17:50:11 +03:00
- [Introduction to Azure Cosmos DB for NoSQL queries ](https://docs.microsoft.com/azure/cosmos-db/sql-api-sql-query )
2019-07-17 16:48:30 +03:00
- [SDK API ](https://docs.microsoft.com/dotnet/api/microsoft.azure.cosmos?view=azure-dotnet )
- [Using emulator ](https://github.com/Azure/azure-documentdb-dotnet/blob/master/docs/documentdb-nosql-local-emulator.md )
- [Capture traces ](https://github.com/Azure/azure-documentdb-dotnet/blob/master/docs/documentdb-sdk_capture_etl.md )
- [Release notes ](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md )
- [Diagnose and troubleshooting ](https://docs.microsoft.com/azure/cosmos-db/troubleshoot-dot-net-sdk )
2019-08-14 22:17:34 +03:00
## Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct ](https://opensource.microsoft.com/codeofconduct/ ).
Resources:
- [Microsoft Open Source Code of Conduct ](https://opensource.microsoft.com/codeofconduct/ )
- [Microsoft Code of Conduct FAQ ](https://opensource.microsoft.com/codeofconduct/faq/ )
- Contact [opencode@microsoft.com ](mailto:opencode@microsoft.com ) with questions or concerns
2019-07-17 16:48:30 +03:00
## Contributing
2018-11-05 21:03:21 +03:00
2022-07-26 18:34:12 +03:00
For details on contributing to this repository, see the [contributing guide ](CONTRIBUTING.md ).
2018-11-05 21:03:21 +03:00
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct ](https://opensource.microsoft.com/codeofconduct/ ).
For more information see the [Code of Conduct FAQ ](https://opensource.microsoft.com/codeofconduct/faq/ ) or
contact [opencode@microsoft.com ](mailto:opencode@microsoft.com ) with any additional questions or comments.