Skip to content
Docs Try Aspire

AzureContainerAppExtensions Methods

Class Methods 7 members
Provides extension methods for customizing Azure Container App definitions for projects.
AddAzureContainerAppEnvironment(IDistributedApplicationBuilder, string) Section titled AddAzureContainerAppEnvironment(IDistributedApplicationBuilder, string) extension IResourceBuilder<AzureContainerAppEnvironmentResource>
Adds a container app environment resource to the distributed application builder.
public static class AzureContainerAppExtensions
{
public static IResourceBuilder<AzureContainerAppEnvironmentResource> AddAzureContainerAppEnvironment(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builder IDistributedApplicationBuilder The distributed application builder.
name string The name of the resource.
IResourceBuilder<AzureContainerAppEnvironmentResource> ApplicationModel.IResourceBuilder`1
AddAzureContainerAppsInfrastructure(IDistributedApplicationBuilder) Section titled AddAzureContainerAppsInfrastructure(IDistributedApplicationBuilder) extension IDistributedApplicationBuilder
Adds the necessary infrastructure for Azure Container Apps to the distributed application builder.
public static class AzureContainerAppExtensions
{
public static IDistributedApplicationBuilder AddAzureContainerAppsInfrastructure(
this IDistributedApplicationBuilder builder)
{
// ...
}
}
builder IDistributedApplicationBuilder The distributed application builder.
WithAzdResourceNaming(IResourceBuilder<AzureContainerAppEnvironmentResource>) Section titled WithAzdResourceNaming(IResourceBuilder<AzureContainerAppEnvironmentResource>) extension IResourceBuilder<AzureContainerAppEnvironmentResource>
Configures the container app environment resources to use the same naming conventions as azd.
public static class AzureContainerAppExtensions
{
public static IResourceBuilder<AzureContainerAppEnvironmentResource> WithAzdResourceNaming(
this IResourceBuilder<AzureContainerAppEnvironmentResource> builder)
{
// ...
}
}
builder IResourceBuilder<AzureContainerAppEnvironmentResource> The AzureContainerAppEnvironmentResource to configure.
IResourceBuilder<AzureContainerAppEnvironmentResource> ApplicationModel.IResourceBuilder`1
By default, the container app environment resources use a different naming convention than azd. This method allows for reusing the previously deployed resources if the application was deployed using azd without calling AzureContainerAppExtensions.AddAzureContainerAppEnvironment
WithAzureLogAnalyticsWorkspace(IResourceBuilder<AzureContainerAppEnvironmentResource>, IResourceBuilder<AzureLogAnalyticsWorkspaceResource>) Section titled WithAzureLogAnalyticsWorkspace(IResourceBuilder<AzureContainerAppEnvironmentResource>, IResourceBuilder<AzureLogAnalyticsWorkspaceResource>) extension IResourceBuilder<AzureContainerAppEnvironmentResource>
Configures the container app environment resource to use the specified Log Analytics Workspace.
public static class AzureContainerAppExtensions
{
public static IResourceBuilder<AzureContainerAppEnvironmentResource> WithAzureLogAnalyticsWorkspace(
this IResourceBuilder<AzureContainerAppEnvironmentResource> builder,
IResourceBuilder<AzureLogAnalyticsWorkspaceResource> workspaceBuilder)
{
// ...
}
}
builder IResourceBuilder<AzureContainerAppEnvironmentResource> The AzureContainerAppEnvironmentResource to configure.
workspaceBuilder IResourceBuilder<AzureLogAnalyticsWorkspaceResource> The resource builder for the Azure.AzureLogAnalyticsWorkspaceResource to use.
IResourceBuilder<AzureContainerAppEnvironmentResource> ApplicationModel.IResourceBuilder`1
ArgumentNullException Thrown when builder or workspaceBuilder is null.
WithCompactResourceNaming(IResourceBuilder<AzureContainerAppEnvironmentResource>) Section titled WithCompactResourceNaming(IResourceBuilder<AzureContainerAppEnvironmentResource>) extension IResourceBuilder<AzureContainerAppEnvironmentResource>
Configures the container app environment to use compact resource naming that maximally preserves the uniqueString suffix for length-constrained Azure resources such as storage accounts.
public static class AzureContainerAppExtensions
{
public static IResourceBuilder<AzureContainerAppEnvironmentResource> WithCompactResourceNaming(
this IResourceBuilder<AzureContainerAppEnvironmentResource> builder)
{
// ...
}
}
builder IResourceBuilder<AzureContainerAppEnvironmentResource> The AzureContainerAppEnvironmentResource to configure.
IResourceBuilder<AzureContainerAppEnvironmentResource> A reference to the ApplicationModel.IResourceBuilder`1 for chaining.

By default, the generated Azure resource names use long static suffixes (e.g. storageVolume, managedStorage) that can consume most of the 24-character storage account name limit, truncating the uniqueString(resourceGroup().id) portion that provides cross-deployment uniqueness.

When enabled, this method shortens the static portions of generated names so the full 13-character uniqueString is preserved. This prevents naming collisions when deploying multiple environments to different resource groups.

This option only affects volume-related storage resources. It does not change the naming of the container app environment, container registry, log analytics workspace, or managed identity. Use AzureContainerAppExtensions.WithAzdResourceNaming to change those names as well.

WithDashboard(IResourceBuilder<AzureContainerAppEnvironmentResource>, bool) Section titled WithDashboard(IResourceBuilder<AzureContainerAppEnvironmentResource>, bool) extension IResourceBuilder<AzureContainerAppEnvironmentResource>
Configures whether the Aspire dashboard should be included in the container app environment.
public static class AzureContainerAppExtensions
{
public static IResourceBuilder<AzureContainerAppEnvironmentResource> WithDashboard(
this IResourceBuilder<AzureContainerAppEnvironmentResource> builder,
bool enable = true)
{
// ...
}
}
builder IResourceBuilder<AzureContainerAppEnvironmentResource> The AzureContainerAppEnvironmentResource to configure.
enable bool optional Whether to include the Aspire dashboard. Default is true.
IResourceBuilder<AzureContainerAppEnvironmentResource> ApplicationModel.IResourceBuilder`1
WithHttpsUpgrade(IResourceBuilder<AzureContainerAppEnvironmentResource>, bool) Section titled WithHttpsUpgrade(IResourceBuilder<AzureContainerAppEnvironmentResource>, bool) extension IResourceBuilder<AzureContainerAppEnvironmentResource>
Configures whether HTTP endpoints should be upgraded to HTTPS in Azure Container Apps. By default, HTTP endpoints are upgraded to HTTPS for security and WebSocket compatibility.
public static class AzureContainerAppExtensions
{
public static IResourceBuilder<AzureContainerAppEnvironmentResource> WithHttpsUpgrade(
this IResourceBuilder<AzureContainerAppEnvironmentResource> builder,
bool upgrade = true)
{
// ...
}
}
builder IResourceBuilder<AzureContainerAppEnvironmentResource> The AzureContainerAppEnvironmentResource to configure.
upgrade bool optional Whether to upgrade HTTP endpoints to HTTPS. Default is true.
IResourceBuilder<AzureContainerAppEnvironmentResource> ApplicationModel.IResourceBuilder`1
When disabled ( false), HTTP endpoints will use HTTP scheme and port 80 in Azure Container Apps. Note that explicit ports specified for development (e.g., port 8080) are still normalized to standard ports (80/443) as required by Azure Container Apps.