Aspire.Hosting.Azure.Kubernetes
17.0.0
Prefix Reserved
dotnet add package Aspire.Hosting.Azure.Kubernetes --version 17.0.0
NuGet\Install-Package Aspire.Hosting.Azure.Kubernetes -Version 17.0.0
<PackageReference Include="Aspire.Hosting.Azure.Kubernetes" Version="17.0.0" />
<PackageVersion Include="Aspire.Hosting.Azure.Kubernetes" Version="17.0.0" />
<PackageReference Include="Aspire.Hosting.Azure.Kubernetes" />
paket add Aspire.Hosting.Azure.Kubernetes --version 17.0.0
#r "nuget: Aspire.Hosting.Azure.Kubernetes, 17.0.0"
#:package Aspire.Hosting.Azure.Kubernetes@17.0.0
#addin nuget:?package=Aspire.Hosting.Azure.Kubernetes&version=17.0.0
#tool nuget:?package=Aspire.Hosting.Azure.Kubernetes&version=17.0.0
Azure Kubernetes Service hosting integration
Use this integration to model, configure, and orchestrate an Azure Kubernetes Service (AKS) environment in an Aspire solution.
Getting started
Prerequisites
- An Azure subscription - create one for free
- Helm v4.0.0 or later on your
PATH.
Aspire shells out to helm upgrade --install to deploy the generated chart and any AddHelmChart(...) releases, and validates the Helm version up front so missing or older installs produce a clear actionable error instead of cryptic flag failures.
Add the integration
From your AppHost directory, add the Aspire.Hosting.Azure.Kubernetes integration with the Aspire CLI:
aspire add Aspire.Hosting.Azure.Kubernetes
aspire add Aspire.Hosting.Dotnet
Usage example
In the AppHost, add an AKS environment and deploy services to it:
C#
var aks = builder.AddAzureKubernetesEnvironment("aks");
var myService = builder.AddDotnetProject("myservice", "../MyService/MyService.csproj")
.WithComputeEnvironment(aks);
TypeScript
const aks = await builder.addAzureKubernetesEnvironment("aks");
const myService = await builder.addNodeApp("myService", "../my-service", "server.js")
.withComputeEnvironment(aks);
Existing clusters
Use the shared Azure existing-resource APIs to deploy to a pre-provisioned AKS cluster:
var clusterName = builder.AddParameter("cluster-name");
var resourceGroup = builder.AddParameter("cluster-resource-group");
var subscription = builder.AddParameter("cluster-subscription");
var aks = builder.AddAzureKubernetesEnvironment("aks")
.AsExistingInResourceGroup(clusterName, resourceGroup, subscription);
Use AsExisting(clusterName, null) when the cluster is in the application's Azure resource group. PublishAsExisting applies only when publishing/deploying.
An explicit existing-cluster resource group and subscription select the cluster independently of Resource.Scope, which controls the module deploying supporting infrastructure. A resource-group-only cluster reference inherits the module's subscription; an unscoped reference inherits its resource group too. Credential retrieval uses the cluster resource ID returned by provisioning.
Aspire references the cluster without changing its node pools, networking, or add-ons, and does not assign workloads to an automatically created workload node pool. Cluster-creation settings do not reconfigure an existing cluster. Explicit node-pool affinity must name a pool that already exists. The cluster must have a kubelet managed identity for registry access; workloads using Azure workload identity also require OIDC and workload identity to be enabled beforehand. Any ingress add-ons used by the application must already be installed and configured.
Existing private clusters can have their public DNS name disabled. The cluster FQDN output falls back to the private DNS name, or an empty string if neither name is available. Deploying to a private cluster still requires network connectivity and DNS resolution from the deployment host.
Aspire still provisions the default container registry, grants the cluster's kubelet identity AcrPull access, and creates workload identity federated credentials when needed. The deploying identity needs permission to create these supporting resources and role assignments, retrieve AKS credentials, and deploy Kubernetes workloads. aspire destroy removes the application's workloads and deletes the application's Azure resource group. Keep the existing cluster in a separate resource group if it must survive aspire destroy.
Node pool configuration
Use callbacks to configure system and user node pools. Both receive an AksNodePoolConfig with a VM size of Standard_D2s_v5 and an autoscaling range of 1-3 nodes. User pools can scale to zero; system pools require at least one node.
C#
var aks = builder.AddAzureKubernetesEnvironment("aks")
.WithSystemNodePool(pool =>
{
pool.VmSize = "Standard_D2as_v5";
pool.OsSku = "AzureLinux";
});
var workers = aks.AddNodePool("workers", pool =>
{
pool.MinCount = 0;
pool.MaxCount = 5;
pool.OsSku = "AzureLinux";
});
TypeScript
const aks = await builder.addAzureKubernetesEnvironment("aks");
await aks.withSystemNodePool(async pool => {
pool.vmSize = "Standard_D2as_v5";
pool.osSku = "AzureLinux";
});
const workers = await aks.addNodePool("workers", async pool => {
pool.minCount = 0;
pool.maxCount = 5;
pool.osSku = "AzureLinux";
});
OsSku / osSku is optional. Leaving it unset omits osSKU from the generated Bicep and preserves the AKS default, including for automatically created pools. Values such as AzureLinux and Ubuntu select the OS SKU, not a specific OS image version; Azure validates availability and compatibility. These APIs configure Linux node pools.
Each WithSystemNodePool call replaces the previous system-pool configuration, including its OS SKU. The selected value is part of the app model and is retained when deployment regenerates Bicep. Changing the OS SKU of an existing pool can reimage nodes and disrupt workloads; follow the AKS OS SKU migration guidance.
The C# callback receives the configuration stored in the app model, not a copy. Extensions can compose further changes through the retained configuration or workers.Resource.Config until infrastructure generation. The final values are validated and applied to the generated Bicep at that point; later mutations do not change files already generated.
Existing parameter-based C# calls remain supported. TypeScript calls using scalar options must migrate to callbacks: replace await aks.withSystemNodePool({ vmSize: "Standard_D2as_v5" }) with the callback above, and replace await aks.addNodePool("workers", { minCount: 0 }) with await aks.addNodePool("workers", async pool => { pool.minCount = 0; }). Polyglot callbacks receive local data whose property changes are written back when the callback returns. Assign properties directly, without remote setters or per-property await.
Existing container registries
Use an existing Azure Container Registry, including one in another resource group:
C#
var registry = builder.AddAzureContainerRegistry("registry")
.PublishAsExisting("myregistry", "registry-resource-group");
var aks = builder.AddAzureKubernetesEnvironment("aks")
.WithContainerRegistry(registry);
TypeScript
const registry = await builder.addAzureContainerRegistry("registry");
await registry.publishAsExisting("myregistry", { resourceGroup: "registry-resource-group" });
const aks = await builder.addAzureKubernetesEnvironment("aks");
await aks.withContainerRegistry(registry);
Aspire grants the AKS kubelet identity AcrPull at the registry's scope, independently of the cluster's resource group or subscription. This applies to both new and existing clusters and registries. For an existing cluster, Aspire reads its kubelet identity and deploys the grant in a separate module without creating a replacement identity. The deployment identity must have permission to create role assignments at the registry's scope, as well as push images to the registry.
aspire destroy preserves the existing registry only when it is outside the application's resource group. It deletes the entire application resource group, including any existing resources in that group, even those configured with PublishAsExisting. A registry in that group and its images are deleted.
AcrPull permits pulling images from every repository in the registry, including unrelated images in a shared registry. This is the same permission used for an automatically created registry. Workloads can potentially obtain kubelet identity tokens through the node's Instance Metadata Service (IMDS); enabling Workload Identity alone does not prevent this. Enforce workload isolation and review the AKS IMDS restriction guidance, including its preview status and host-network and privileged-workload limitations.
aspire destroy does not remove role assignments on a registry outside the application's resource group. Remove the kubelet's role assignment separately when it is no longer needed. Deleting its managed identity does not delete these external assignments.
Cluster identities and permissions
For newly provisioned clusters, Aspire provisions separate user-assigned managed identities for the control plane and kubelets. Both inherit the cluster's resource-group and subscription scope, including scopes set through provisioning customization. Neither is a workload identity:
| Identity | Permissions |
|---|---|
| Kubelet | AcrPull on the selected registry. |
| Control plane | Managed Identity Operator on the kubelet identity, and Network Contributor on virtual networks selected through environment or node-pool WithSubnet calls. |
These role assignments are provisioned before the cluster. AKS grants the control-plane identity its normal infrastructure permissions in the AKS-managed node resource group; Aspire does not grant Contributor on the application resource group or subscription. If provisioning customization references other external resources, such as route tables, network security groups, or private DNS zones, configure the corresponding control-plane permissions separately. See AKS managed identity role assignments.
The registry must use RBAC Registry Permissions mode for AcrPull to authorize image pulls. Registries using RBAC Registry + ABAC Repository Permissions mode require different roles and are not configured automatically by this integration.
Updating existing clusters
Clusters deployed with earlier versions used a system-assigned control-plane identity and an AKS-created kubelet identity. Redeploying with this version changes both identities. Changing the kubelet identity can trigger node-pool upgrades, which drain and reimage nodes and can disrupt workloads. Schedule the migration accordingly and follow the pre-created kubelet identity guidance.
Custom role assignments on the old identities are not transferred automatically. Grant any additional permissions to the new identities before migration, and retain the old permissions until the control plane has switched identities and node pools have finished updating. The control plane can continue using its previous identity for several hours while cached tokens expire. Remove obsolete external assignments afterward.
Cluster tier
AKS clusters use the Standard control-plane tier by default, providing an uptime SLA for production workloads. Standard includes a cluster-management charge in addition to the underlying Azure resource costs. See AKS pricing tiers for current details.
Applying updated infrastructure to an existing Aspire-managed cluster changes its tier to Standard unless explicitly overridden. Upgrading the integration package alone does not change a deployed cluster.
To use the Free tier for development or testing, customize the infrastructure in a C# AppHost:
using Azure.Provisioning.ContainerService;
var aks = builder.AddAzureKubernetesEnvironment("aks")
.ConfigureInfrastructure(infrastructure =>
{
var cluster = infrastructure.GetProvisionableResources()
.OfType<ContainerServiceManagedCluster>()
.Single();
cluster.Sku.Tier = ManagedClusterSkuTier.Free;
});
The control-plane tier does not change node VM sizes or provide an application availability guarantee.
Persistent volumes
Add a persistent volume to the AKS environment and mount it into a workload:
C#
var data = aks.AddPersistentVolume("data")
.WithCapacity("20Gi");
myService.WithPersistentVolume(data, "/data", env: "DATA_PATH");
TypeScript
const data = await aks.addPersistentVolume("data");
await data.withCapacity("20Gi");
await myService.withKubernetesPersistentVolumeMount(data, "/data", { env: "DATA_PATH" });
When a project or executable runs locally, DATA_PATH points to a persistent directory in the AppHost's Aspire store. That store is normally under the AppHost intermediate-output directory, so cleaning build outputs can remove the local data. Local containers use a worktree-scoped container volume instead when the mount names an environment variable, and one persistent-volume resource cannot be shared between local containers and local projects or executables.
In AKS, DATA_PATH contains /data, the mounted volume path. When no storage class is specified, the generated claim uses the cluster's default storage class. A standard AKS cluster dynamically provisions an Azure managed disk. To request Premium SSD storage explicitly, call WithStorageClass("managed-csi-premium") in C# or withStorageClass("managed-csi-premium") in TypeScript.
Additional documentation
- https://aspire.dev/integrations/gallery/
- https://aspire.dev/integrations/cloud/azure/aks/
- https://learn.microsoft.com/azure/aks/
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 (>= 17.0.0)
- Aspire.Hosting.Azure.ContainerRegistry (>= 17.0.0)
- Aspire.Hosting.Azure.Network (>= 17.0.0)
- Aspire.Hosting.Azure.OperationalInsights (>= 17.0.0)
- Aspire.Hosting.Kubernetes (>= 17.0.0)
- AspNetCore.HealthChecks.Uris (>= 9.0.0)
- Azure.Core (>= 1.63.0)
- Azure.Identity (>= 1.21.0)
- Azure.Provisioning (>= 1.6.0)
- Azure.Provisioning.ContainerRegistry (>= 1.1.0)
- Azure.Provisioning.ContainerService (>= 1.0.0)
- Azure.Provisioning.KeyVault (>= 1.1.0)
- Azure.Provisioning.Network (>= 1.1.0)
- Azure.Provisioning.OperationalInsights (>= 1.1.0)
- Azure.Provisioning.PrivateDns (>= 1.0.0)
- 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)
- Google.Protobuf (>= 3.36.1)
- Grpc.AspNetCore (>= 2.83.0)
- Grpc.Net.ClientFactory (>= 2.83.0)
- Grpc.Tools (>= 2.83.0)
- Hex1b (>= 0.173.0)
- KubernetesClient (>= 19.0.2)
- MessagePack (>= 2.5.307)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.15)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.15)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.15)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.15)
- Microsoft.Extensions.Hosting (>= 10.0.15)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Http (>= 10.0.15)
- Microsoft.Extensions.Logging (>= 10.0.15)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.15)
- Microsoft.Extensions.Options (>= 10.0.15)
- Microsoft.Extensions.Primitives (>= 10.0.15)
- ModelContextProtocol (>= 1.4.1)
- NCrontab.Signed (>= 3.4.0)
- Newtonsoft.Json (>= 13.0.4)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.18.0)
- OpenTelemetry.Extensions.Hosting (>= 1.18.0)
- Polly.Core (>= 8.7.0)
- Semver (>= 3.0.0)
- StreamJsonRpc (>= 2.25.29)
- System.IO.Hashing (>= 10.0.15)
- YamlDotNet (>= 18.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aspire.Hosting.Azure.Kubernetes:
| Package | Downloads |
|---|---|
|
Aspire.Hosting.Azure.Provisioning.ContainerService
Opt-in Azure Provisioning Container Service APIs for polyglot Aspire AppHosts. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 17.0.0 | 191 | 11/18/2026 |
| 13.6.5-preview.1.26559.7 | 107 | 11/10/2026 |
| 13.6.4-preview.1.26523.11 | 125 | 10/24/2026 |
| 13.6.3-preview.1.26521.2 | 75 | 10/21/2026 |
| 13.6.2-preview.1.26519.11 | 88 | 10/20/2026 |
| 13.6.1-preview.1.26506.6 | 122 | 10/7/2026 |
| 13.6.0-preview.1.26479.8 | 213 | 9/29/2026 |
| 13.5.4-preview.1.26464.4 | 151 | 9/15/2026 |
| 13.5.3-preview.1.26425.3 | 700 | 8/25/2026 |
| 13.5.2-preview.1.26421.6 | 331 | 8/21/2026 |
| 13.5.1-preview.1.26420.4 | 99 | 8/20/2026 |
| 13.5.0-preview.1.26417.10 | 116 | 8/18/2026 |
| 13.4.6-preview.1.26319.6 | 1,275 | 6/19/2026 |
| 13.4.5-preview.1.26316.12 | 147 | 6/17/2026 |
| 13.4.4-preview.1.26314.3 | 191 | 6/15/2026 |
| 13.4.3-preview.1.26305.13 | 132 | 6/8/2026 |
| 13.4.2-preview.1.26303.6 | 134 | 6/3/2026 |
| 13.4.1-preview.1.26303.3 | 108 | 6/3/2026 |
| 13.4.0-preview.1.26281.18 | 114 | 6/1/2026 |
| 13.3.5-preview.1.26270.6 | 159 | 5/21/2026 |