Aspire.Hosting.Azure.Sql
13.6.4
Prefix Reserved
dotnet add package Aspire.Hosting.Azure.Sql --version 13.6.4
NuGet\Install-Package Aspire.Hosting.Azure.Sql -Version 13.6.4
<PackageReference Include="Aspire.Hosting.Azure.Sql" Version="13.6.4" />
<PackageVersion Include="Aspire.Hosting.Azure.Sql" Version="13.6.4" />
<PackageReference Include="Aspire.Hosting.Azure.Sql" />
paket add Aspire.Hosting.Azure.Sql --version 13.6.4
#r "nuget: Aspire.Hosting.Azure.Sql, 13.6.4"
#:package Aspire.Hosting.Azure.Sql@13.6.4
#addin nuget:?package=Aspire.Hosting.Azure.Sql&version=13.6.4
#tool nuget:?package=Aspire.Hosting.Azure.Sql&version=13.6.4
Azure SQL Database hosting integration
Use this integration to model, configure, and orchestrate Azure SQL DB 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.Sql integration with the Aspire CLI:
aspire add Aspire.Hosting.Azure.Sql
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, register a SqlServer database and reference it from another resource with either C# or TypeScript:
C#
var sql = builder.AddAzureSqlServer("sql")
.AddDatabase("sqldata");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(sql);
TypeScript
const sql = await builder.addAzureSqlServer("sql")
.addDatabase("sqldata");
const myService = await builder.addNodeApp("myService", "../my-service", "server.js")
.withReference(sql);
Connection Properties
When you reference Azure SQL Server resources using WithReference, the following connection properties are made available to the consuming project:
Azure SQL Server resource
The Azure SQL Server resource exposes the following connection properties:
| Property Name | Description |
|---|---|
Host |
The fully qualified domain name of the Azure SQL Server |
Port |
The SQL Server port (1433 for Azure) |
Uri |
The connection URI, with the format mssql://{Host}:{Port} |
JdbcConnectionString |
JDBC connection string with the format jdbc:sqlserver://{Host}:{Port};encrypt=true;trustServerCertificate=false; |
Azure SQL database resource
The Azure SQL database resource inherits all properties from its parent Azure SQL Server resource and adds:
| Property Name | Description |
|---|---|
DatabaseName |
The name of the database |
Uri |
The connection URI, with the format mssql://{Host}:{Port}/{DatabaseName} |
JdbcConnectionString |
JDBC connection string with the format jdbc:sqlserver://{Host}:{Port};database={DatabaseName};encrypt=true;trustServerCertificate=false; |
Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called db1 becomes DB1_URI.
The client should add a valid authentication property for the JDBC connection string like authentication=ActiveDirectoryDefault or authentication=ActiveDirectoryManagedIdentity.
Azure SQL DB defaults
Unless otherwise specified, the Azure SQL DB created will be a 2vCores General Purpose Serverless database (GP_S_Gen5_2) with the free offer enabled.
Read more about the free offer here: Deploy Azure SQL Database for free
The free offer is configured so that when the maximum usage limit is reached, the database is stopped to avoid incurring in unexpected costs.
If you don't want to use the free offer and instead deploy the database use the default sku set by Azure, use the WithAzureDefaultSku method:
var sql = builder.AddAzureSqlServer("sql")
.AddDatabase("db", "my-db-name")
.WithAzureDefaultSku();
Setting a specific SKU
If you want to manually define what SKU must be used when deploying the Azure SQL DB resource, use the ConfigureInfrastructure method:
var sqlSrv = builder.AddAzureSqlServer("sqlsrv")
.ConfigureInfrastructure(infra => {
var azureResources = infra.GetProvisionableResources();
var azureDb = azureResources.OfType<SqlDatabase>().Single();
azureDb.Sku = new SqlSku() { Name = "HS_Gen5_2" };
})
.AddDatabase("sqldb", "DatabaseName");
.RunAsContainer();
Additional documentation
- https://aspire.dev/integrations/gallery/
- https://aspire.dev/integrations/cloud/azure/azure-sql-database/azure-sql-database-host/
- https://learn.microsoft.com/azure/azure-sql/
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 is compatible. 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 is compatible. 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. |
-
net10.0
- Aspire.Hosting.Azure (>= 13.6.4)
- Aspire.Hosting.Azure.Network (>= 13.6.4)
- Aspire.Hosting.Azure.Storage (>= 13.6.4)
- Aspire.Hosting.SqlServer (>= 13.6.4)
- AspNetCore.HealthChecks.Azure.Storage.Blobs (>= 9.0.0)
- AspNetCore.HealthChecks.Azure.Storage.Queues (>= 9.0.0)
- AspNetCore.HealthChecks.SqlServer (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Azure.Core (>= 1.62.0)
- Azure.Identity (>= 1.21.0)
- Azure.Provisioning (>= 1.6.0)
- Azure.Provisioning.KeyVault (>= 1.1.0)
- Azure.Provisioning.Network (>= 1.1.0)
- Azure.Provisioning.PrivateDns (>= 1.0.0)
- Azure.Provisioning.Sql (>= 1.1.0)
- Azure.Provisioning.Storage (>= 1.1.2)
- Azure.ResourceManager.Authorization (>= 1.1.7)
- Azure.ResourceManager.KeyVault (>= 1.4.0)
- Azure.ResourceManager.Resources.Deployments (>= 1.0.0)
- Azure.Security.KeyVault.Secrets (>= 4.11.1)
- Azure.Storage.Blobs (>= 12.29.2)
- Azure.Storage.Files.DataLake (>= 12.27.1)
- Azure.Storage.Queues (>= 12.27.1)
- Google.Protobuf (>= 3.36.1)
- Grpc.AspNetCore (>= 2.83.0)
- Grpc.Net.ClientFactory (>= 2.83.0)
- Grpc.Tools (>= 2.83.0)
- Hex1b (>= 0.168.0)
- KubernetesClient (>= 19.0.2)
- MessagePack (>= 2.5.307)
- Microsoft.Bcl.Cryptography (>= 10.0.12)
- Microsoft.Data.SqlClient (>= 7.0.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.12)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.12)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.12)
- Microsoft.Extensions.Hosting (>= 10.0.12)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Microsoft.Extensions.Primitives (>= 10.0.12)
- ModelContextProtocol (>= 1.4.1)
- Newtonsoft.Json (>= 13.0.4)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.17.0)
- OpenTelemetry.Extensions.Hosting (>= 1.17.0)
- Polly.Core (>= 8.7.0)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.25.29)
- System.IO.Hashing (>= 10.0.12)
- System.Security.Cryptography.Pkcs (>= 10.0.12)
- YamlDotNet (>= 18.1.0)
-
net8.0
- Aspire.Hosting.Azure (>= 13.6.4)
- Aspire.Hosting.Azure.Network (>= 13.6.4)
- Aspire.Hosting.Azure.Storage (>= 13.6.4)
- Aspire.Hosting.SqlServer (>= 13.6.4)
- AspNetCore.HealthChecks.Azure.Storage.Blobs (>= 9.0.0)
- AspNetCore.HealthChecks.Azure.Storage.Queues (>= 9.0.0)
- AspNetCore.HealthChecks.SqlServer (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Azure.Core (>= 1.62.0)
- Azure.Identity (>= 1.21.0)
- Azure.Provisioning (>= 1.6.0)
- Azure.Provisioning.KeyVault (>= 1.1.0)
- Azure.Provisioning.Network (>= 1.1.0)
- Azure.Provisioning.PrivateDns (>= 1.0.0)
- Azure.Provisioning.Sql (>= 1.1.0)
- Azure.Provisioning.Storage (>= 1.1.2)
- Azure.ResourceManager.Authorization (>= 1.1.7)
- Azure.ResourceManager.KeyVault (>= 1.4.0)
- Azure.ResourceManager.Resources.Deployments (>= 1.0.0)
- Azure.Security.KeyVault.Secrets (>= 4.11.1)
- Azure.Storage.Blobs (>= 12.29.2)
- Azure.Storage.Files.DataLake (>= 12.27.1)
- Azure.Storage.Queues (>= 12.27.1)
- Google.Protobuf (>= 3.36.1)
- Grpc.AspNetCore (>= 2.83.0)
- Grpc.Net.ClientFactory (>= 2.83.0)
- Grpc.Tools (>= 2.83.0)
- Hex1b (>= 0.168.0)
- KubernetesClient (>= 19.0.2)
- MessagePack (>= 2.5.307)
- Microsoft.Bcl.Cryptography (>= 10.0.12)
- Microsoft.Data.SqlClient (>= 7.0.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.12)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.31)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.12)
- Microsoft.Extensions.Hosting (>= 10.0.12)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Microsoft.Extensions.Primitives (>= 10.0.12)
- ModelContextProtocol (>= 1.4.1)
- Newtonsoft.Json (>= 13.0.4)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.17.0)
- OpenTelemetry.Extensions.Hosting (>= 1.17.0)
- Polly.Core (>= 8.7.0)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.25.29)
- System.Formats.Asn1 (>= 10.0.12)
- System.IO.Hashing (>= 10.0.12)
- System.Security.Cryptography.Pkcs (>= 10.0.12)
- System.Text.Json (>= 10.0.12)
- YamlDotNet (>= 18.1.0)
-
net9.0
- Aspire.Hosting.Azure (>= 13.6.4)
- Aspire.Hosting.Azure.Network (>= 13.6.4)
- Aspire.Hosting.Azure.Storage (>= 13.6.4)
- Aspire.Hosting.SqlServer (>= 13.6.4)
- AspNetCore.HealthChecks.Azure.Storage.Blobs (>= 9.0.0)
- AspNetCore.HealthChecks.Azure.Storage.Queues (>= 9.0.0)
- AspNetCore.HealthChecks.SqlServer (>= 9.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Azure.Core (>= 1.62.0)
- Azure.Identity (>= 1.21.0)
- Azure.Provisioning (>= 1.6.0)
- Azure.Provisioning.KeyVault (>= 1.1.0)
- Azure.Provisioning.Network (>= 1.1.0)
- Azure.Provisioning.PrivateDns (>= 1.0.0)
- Azure.Provisioning.Sql (>= 1.1.0)
- Azure.Provisioning.Storage (>= 1.1.2)
- Azure.ResourceManager.Authorization (>= 1.1.7)
- Azure.ResourceManager.KeyVault (>= 1.4.0)
- Azure.ResourceManager.Resources.Deployments (>= 1.0.0)
- Azure.Security.KeyVault.Secrets (>= 4.11.1)
- Azure.Storage.Blobs (>= 12.29.2)
- Azure.Storage.Files.DataLake (>= 12.27.1)
- Azure.Storage.Queues (>= 12.27.1)
- Google.Protobuf (>= 3.36.1)
- Grpc.AspNetCore (>= 2.83.0)
- Grpc.Net.ClientFactory (>= 2.83.0)
- Grpc.Tools (>= 2.83.0)
- Hex1b (>= 0.168.0)
- KubernetesClient (>= 19.0.2)
- MessagePack (>= 2.5.307)
- Microsoft.Bcl.Cryptography (>= 10.0.12)
- Microsoft.Data.SqlClient (>= 7.0.2)
- Microsoft.Extensions.Caching.Memory (>= 10.0.12)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.20)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.12)
- Microsoft.Extensions.Hosting (>= 10.0.12)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Microsoft.Extensions.Primitives (>= 10.0.12)
- ModelContextProtocol (>= 1.4.1)
- Newtonsoft.Json (>= 13.0.4)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.17.0)
- OpenTelemetry.Extensions.Hosting (>= 1.17.0)
- Polly.Core (>= 8.7.0)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.25.29)
- System.Formats.Asn1 (>= 10.0.12)
- System.IO.Hashing (>= 10.0.12)
- System.Security.Cryptography.Pkcs (>= 10.0.12)
- System.Text.Json (>= 10.0.12)
- YamlDotNet (>= 18.1.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Aspire.Hosting.Azure.Sql:
| Package | Downloads |
|---|---|
|
Toxic.Aspire.NamingConventions.Azure
Contains a framework for automatically generating Aspire Azure resource names according to conventions. |
|
|
Extensions.Aspire.SqlServer
Extensions for SQL Server Aspire integration |
|
|
Wicksipedia.Aspire.Hosting.Azure.SqlRoles
Grant Azure SQL managed identities least-privilege database roles (db_datareader, db_datawriter, …) from an Aspire AppHost, instead of Aspire's built-in db_owner-for-every-identity — including the in-VNet grant-script plumbing needed when the SQL server is behind a private endpoint. |
|
|
Aspire.Hosting.Azure.Provisioning.Sql
Opt-in Azure Provisioning SQL APIs for polyglot Aspire AppHosts. |
|
|
Wicksipedia.Aspire.Helpers.SqlRoles
Grant Azure SQL managed identities least-privilege database roles (db_datareader, db_datawriter, …) from a .NET Aspire AppHost, instead of Aspire's built-in db_owner-for-every-identity — including the in-VNet grant-script plumbing needed when the SQL server is behind a private endpoint. |
GitHub repositories (6)
Showing the top 6 popular GitHub repositories that depend on Aspire.Hosting.Azure.Sql:
| Repository | Stars |
|---|---|
|
jasontaylordev/CleanArchitecture
Clean Architecture Solution Template for ASP.NET Core
|
|
|
SSWConsulting/SSW.VerticalSliceArchitecture
An enterprise ready solution template for Vertical Slice Architecture. This template is just one way to apply the Vertical Slice Architecture.
|
|
|
rstropek/Samples
|
|
|
SSWConsulting/SSW.CleanArchitecture
SSW Clean Architecture Template
|
|
|
Keboo/DotnetTemplates
A repository for my dotnet templates
|
|
|
PacktPublishing/Pragmatic-Microservices-with-CSharp-and-Azure
Pragmatic Microservices with C# and Azure, published by Packt
|
| Version | Downloads | Last Updated |
|---|---|---|
| 13.6.4 | 3,609 | 10/24/2026 |
| 13.6.3 | 2,810 | 10/21/2026 |
| 13.6.2 | 1,742 | 10/20/2026 |
| 13.6.1 | 41,431 | 10/7/2026 |
| 13.6.0 | 27,698 | 9/29/2026 |
| 13.5.4 | 40,737 | 9/15/2026 |
| 13.5.3 | 82,323 | 8/25/2026 |
| 13.5.2 | 20,031 | 8/21/2026 |
| 13.5.1 | 3,041 | 8/20/2026 |
| 13.5.0 | 7,711 | 8/18/2026 |
| 13.4.6 | 153,426 | 6/19/2026 |
| 13.4.5 | 6,959 | 6/17/2026 |
| 13.4.4 | 24,867 | 6/15/2026 |
| 13.4.3 | 15,611 | 6/8/2026 |
| 13.4.2 | 13,174 | 6/3/2026 |
| 13.4.1 | 1,543 | 6/3/2026 |
| 13.4.0 | 6,783 | 6/1/2026 |
| 13.3.5 | 40,716 | 5/21/2026 |
| 13.3.4 | 7,031 | 5/19/2026 |
| 13.3.3 | 10,818 | 5/15/2026 |