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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aspire.Hosting.Azure.Sql" Version="13.6.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aspire.Hosting.Azure.Sql" Version="13.6.4" />
                    
Directory.Packages.props
<PackageReference Include="Aspire.Hosting.Azure.Sql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aspire.Hosting.Azure.Sql --version 13.6.4
                    
#r "nuget: Aspire.Hosting.Azure.Sql, 13.6.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aspire.Hosting.Azure.Sql@13.6.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aspire.Hosting.Azure.Sql&version=13.6.4
                    
Install as a Cake Addin
#tool nuget:?package=Aspire.Hosting.Azure.Sql&version=13.6.4
                    
Install as a Cake Tool

Azure SQL Database hosting integration

Use this integration to model, configure, and orchestrate Azure SQL DB in an Aspire solution.

Getting started

Prerequisites

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

Feedback & contributing

https://github.com/microsoft/aspire

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed