Aspire.Hosting.Azure.CosmosDB
8.0.0-preview.5.24201.12
Prefix Reserved
This version is out of support and is no longer maintained. Please upgrade to the latest version. See our support policy for details: https://aka.ms/dotent/aspire/support
See the version list below for details.
dotnet add package Aspire.Hosting.Azure.CosmosDB --version 8.0.0-preview.5.24201.12
NuGet\Install-Package Aspire.Hosting.Azure.CosmosDB -Version 8.0.0-preview.5.24201.12
<PackageReference Include="Aspire.Hosting.Azure.CosmosDB" Version="8.0.0-preview.5.24201.12" />
<PackageVersion Include="Aspire.Hosting.Azure.CosmosDB" Version="8.0.0-preview.5.24201.12" />
<PackageReference Include="Aspire.Hosting.Azure.CosmosDB" />
paket add Aspire.Hosting.Azure.CosmosDB --version 8.0.0-preview.5.24201.12
#r "nuget: Aspire.Hosting.Azure.CosmosDB, 8.0.0-preview.5.24201.12"
#addin nuget:?package=Aspire.Hosting.Azure.CosmosDB&version=8.0.0-preview.5.24201.12&prerelease
#tool nuget:?package=Aspire.Hosting.Azure.CosmosDB&version=8.0.0-preview.5.24201.12&prerelease
Aspire.Hosting.Azure.Cosmos library
Provides extension methods and resource definitions for a .NET Aspire AppHost to configure Azure CosmosDB.
Getting started
Prerequisites
- Azure subscription - create one for free
- Azure Cosmos DB account - create a Cosmos DB account
Install the package
In your AppHost project, install the .NET Aspire Azure Cosmos DB Hosting library with NuGet:
dotnet add package Aspire.Hosting.Azure.Cosmos
Usage example
Then, in the Program.cs file of AppHost
, add a Cosmos DB connection and consume the connection using the following methods:
var cosmosdb = builder.AddAzureCosmosDB("cdb").AddDatabase("cosmosdb");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(cosmosdb);
The AddAzureCosmosDB
method will read connection information from the AppHost's configuration (for example, from "user secrets") under the ConnectionStrings:cosmosdb
config key. The WithReference
method passes that connection information into a connection string named cosmosdb
in the MyService
project. In the Program.cs file of MyService
, the connection can be consumed using the client library Aspire.Microsoft.Azure.Cosmos:
builder.AddAzureCosmosDBClient("cosmosdb");
Emulator usage
Aspire supports the usage of the Azure Cosmos DB emulator to use the emulator, add the following to your AppHost project:
// AppHost
var cosmosdb = builder.AddAzureCosmosDB("cosmos").RunAsEmulator();
When the AppHost starts up a local container running the Azure CosmosDB will also be started:
// Service code
builder.AddAzureCosmosDbClient("cosmos");
Additional documentation
- https://learn.microsoft.com/azure/cosmos-db/nosql/sdk-dotnet-v3
- https://github.com/dotnet/aspire/tree/main/src/Components/README.md
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 (>= 8.0.0-preview.5.24201.12)
- Azure.Provisioning (>= 0.1.0-beta.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Aspire.Hosting.Azure.CosmosDB:
Package | Downloads |
---|---|
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. |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Aspire.Hosting.Azure.CosmosDB:
Repository | Stars |
---|---|
IEvangelist/azure-cosmos-dotnet-repository
Wraps the .NET SDK for Azure Cosmos DB abstracting away the complexity, exposing a simple CRUD-based repository pattern
|
|
davidfowl/aspire-ai-chat-demo
Aspire AI Chat is a full-stack chat sample that combines modern technologies to deliver a ChatGPT-like experience.
|
Version | Downloads | Last Updated | |
---|---|---|---|
9.3.1 | 5,928 | 6/10/2025 | |
9.3.0 | 11,405 | 5/19/2025 | |
9.2.1 | 10,735 | 4/24/2025 | |
9.2.0 | 8,805 | 4/10/2025 | |
9.1.0 | 21,969 | 2/25/2025 | |
9.0.0 | 50,015 | 11/12/2024 | |
9.0.0-rc.1.24511.1 | 2,358 | 10/15/2024 | |
8.2.2 | 4,944 | 10/24/2024 | |
8.2.1 | 5,783 | 9/26/2024 | |
8.2.0 | 17,036 | 8/29/2024 | |
8.1.0 | 5,677 | 7/23/2024 | |
8.0.2 | 2,683 | 6/28/2024 | |
8.0.1 | 7,630 | 5/21/2024 | |
8.0.0 | 546 | 5/21/2024 | |
8.0.0-preview.7.24251.11 | 897 | 5/7/2024 | |
8.0.0-preview.6.24214.1 | 2,981 | 4/23/2024 | |
8.0.0-preview.5.24201.12 | 448 | 4/9/2024 |