Aspire.Hosting.Azure.CosmosDB
13.5.0
Prefix Reserved
dotnet add package Aspire.Hosting.Azure.CosmosDB --version 13.5.0
NuGet\Install-Package Aspire.Hosting.Azure.CosmosDB -Version 13.5.0
<PackageReference Include="Aspire.Hosting.Azure.CosmosDB" Version="13.5.0" />
<PackageVersion Include="Aspire.Hosting.Azure.CosmosDB" Version="13.5.0" />
<PackageReference Include="Aspire.Hosting.Azure.CosmosDB" />
paket add Aspire.Hosting.Azure.CosmosDB --version 13.5.0
#r "nuget: Aspire.Hosting.Azure.CosmosDB, 13.5.0"
#:package Aspire.Hosting.Azure.CosmosDB@13.5.0
#addin nuget:?package=Aspire.Hosting.Azure.CosmosDB&version=13.5.0
#tool nuget:?package=Aspire.Hosting.Azure.CosmosDB&version=13.5.0
Azure Cosmos DB hosting integration
Use this integration to model, configure, and orchestrate Azure CosmosDB in an Aspire solution.
Getting started
Prerequisites
- Azure subscription - create one for free
Add the integration
From your AppHost directory, add the Aspire.Hosting.Azure.CosmosDB integration with the Aspire CLI:
aspire add Aspire.Hosting.Azure.CosmosDB
Configure Azure Provisioning for local development
Adding Azure resources to the AppHost model will automatically enable development-time provisioning
for Azure resources so that you don't need to configure them manually. Provisioning requires a number of settings
to be available via AppHost configuration. From your AppHost directory, set these values with aspire secret set:
aspire secret set Azure:SubscriptionId "<your subscription id>"
aspire secret set Azure:ResourceGroupPrefix "<prefix for the resource group>"
aspire secret set Azure:Location "<azure location>"
NOTE: Developers must have Owner access to the target subscription so that role assignments can be configured for the provisioned resources.
Usage example
In the AppHost, add a Cosmos DB connection and reference it from another resource with either C# or TypeScript:
C#
var cosmosdb = builder.AddAzureCosmosDB("cdb").AddCosmosDatabase("cosmosdb");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(cosmosdb);
TypeScript
const cosmosdb = await builder.addAzureCosmosDB("cdb").addCosmosDatabase("cosmosdb");
const myService = await builder.addNodeApp("myService", "../my-service", "server.js")
.withReference(cosmosdb);
Connection Properties
When you reference Azure Cosmos DB resources using WithReference, the following connection properties are made available to the consuming project:
Cosmos DB account
The Cosmos DB account resource exposes the following connection properties:
| Property Name | Description |
|---|---|
Uri |
The account endpoint URI for the Cosmos DB account, with the format https://mycosmosaccount.documents.azure.com:443/ |
AccountKey |
The account key for the Cosmos DB account (only available for emulator and access key authentication) |
ConnectionString |
Emulator or access key authentication only. A full connection string (includes account key for emulator; access key secret when access key auth is enabled). |
Cosmos DB database
The Cosmos DB database resource inherits all properties from its parent Cosmos DB account and adds:
| Property Name | Description |
|---|---|
DatabaseName |
The name of the database |
Cosmos DB container
The Cosmos DB container resource inherits all properties from its parent Cosmos DB database and adds:
| Property Name | Description |
|---|---|
ContainerName |
The name of the container |
Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called db1 becomes DB1_URI.
Additional documentation
- https://aspire.dev/integrations/gallery/
- https://aspire.dev/integrations/cloud/azure/azure-cosmos-db/azure-cosmos-db-host/
- https://learn.microsoft.com/azure/cosmos-db/nosql/
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Aspire.Hosting.Azure (>= 13.5.0)
- Aspire.Hosting.Azure.KeyVault (>= 13.5.0)
- AspNetCore.HealthChecks.CosmosDb (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Azure.Core (>= 1.57.0)
- Azure.Identity (>= 1.21.0)
- Azure.Provisioning (>= 1.5.0)
- Azure.Provisioning.CosmosDB (>= 1.0.0)
- Azure.Provisioning.KeyVault (>= 1.1.0)
- Azure.ResourceManager.Authorization (>= 1.1.6)
- Azure.ResourceManager.KeyVault (>= 1.4.0)
- Azure.ResourceManager.Resources (>= 1.11.2)
- Azure.Security.KeyVault.Secrets (>= 4.11.0)
- Google.Protobuf (>= 3.34.1)
- Grpc.AspNetCore (>= 2.80.0)
- Grpc.Net.ClientFactory (>= 2.80.0)
- Grpc.Tools (>= 2.80.0)
- Humanizer.Core (>= 3.0.10)
- JsonPatch.Net (>= 5.0.2)
- KubernetesClient (>= 19.0.2)
- Microsoft.Azure.Cosmos (>= 3.61.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.11)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.11)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.30)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.11)
- Microsoft.Extensions.Hosting (>= 10.0.11)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Http (>= 10.0.11)
- Microsoft.Extensions.Logging (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Options (>= 10.0.11)
- Microsoft.Extensions.Primitives (>= 10.0.11)
- ModelContextProtocol (>= 1.3.0)
- Newtonsoft.Json (>= 13.0.4)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- Polly.Core (>= 8.6.6)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.25.29)
- System.IO.Hashing (>= 10.0.8)
- System.Text.Json (>= 10.0.11)
- YamlDotNet (>= 16.3.0)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Aspire.Hosting.Azure.CosmosDB:
| Package | Downloads |
|---|---|
|
Aspire.Hosting.Foundry
Microsoft Foundry resource types for Aspire. |
|
|
Hexalith.Infrastructure.AspireService.Hosting
Hexalith is a set of libraries to build a micro-service architecture. |
|
|
Hexalith.NetAspire.Hosting
Hexalith is a set of libraries to build an application with micro-service architecture. |
|
|
MMCA.Common.Aspire.Hosting
MMCA framework: Aspire AppHost extension methods for the cross-cutting infrastructure (RabbitMQ broker, JWKS service discovery, gRPC project wiring) used by extracted microservice deployments |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on Aspire.Hosting.Azure.CosmosDB:
| Repository | Stars |
|---|---|
|
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 10, Wolverine, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
|
|
|
IEvangelist/azure-cosmos-dotnet-repository
Wraps the .NET SDK for Azure Cosmos DB abstracting away the complexity, exposing a simple CRUD-based repository pattern
|
|
|
AzureCosmosDB/cosmosdb-nosql-copilot
Build a copilot application with Azure OpenAI Service, Azure Cosmos DB & Azure App Service.
|
|
|
PacktPublishing/Pragmatic-Microservices-with-CSharp-and-Azure
Pragmatic Microservices with C# and Azure, published by Packt
|
| Version | Downloads | Last Updated |
|---|---|---|
| 13.5.0 | 0 | 8/18/2026 |
| 13.4.6 | 133,308 | 6/19/2026 |
| 13.4.5 | 12,940 | 6/17/2026 |
| 13.4.4 | 8,075 | 6/15/2026 |
| 13.4.3 | 24,440 | 6/8/2026 |
| 13.4.2 | 80,616 | 6/3/2026 |
| 13.4.1 | 1,036 | 6/3/2026 |
| 13.4.0 | 36,273 | 6/1/2026 |
| 13.3.5 | 55,097 | 5/21/2026 |
| 13.3.4 | 11,880 | 5/19/2026 |
| 13.3.3 | 14,161 | 5/15/2026 |
| 13.3.2 | 6,264 | 5/14/2026 |
| 13.3.1 | 7,940 | 5/12/2026 |
| 13.3.0 | 15,268 | 5/7/2026 |
| 13.2.4 | 44,522 | 4/24/2026 |
| 13.2.3 | 16,756 | 4/21/2026 |
| 13.2.2 | 62,394 | 4/8/2026 |
| 13.2.1 | 19,892 | 3/31/2026 |
| 13.2.0 | 29,889 | 3/23/2026 |
| 13.1.3 | 10,899 | 3/19/2026 |