Skip to content

Add support to enable regional DNL for Azure App Service#14001

Open
ShilpiRach wants to merge 30 commits intomicrosoft:mainfrom
ShilpiRach:dnlsupport2
Open

Add support to enable regional DNL for Azure App Service#14001
ShilpiRach wants to merge 30 commits intomicrosoft:mainfrom
ShilpiRach:dnlsupport2

Conversation

@ShilpiRach
Copy link
Contributor

@ShilpiRach ShilpiRach commented Jan 19, 2026

Description

Added a feature to enable regional DNL with Scope set to TenantReuse. Regional DNL (Domain Name Label) is the App Service platform feature that generates regionalised, unique default hostnames for Web Apps. Details: https://techcommunity.microsoft.com/blog/azurenetworkingblog/improve-dns-security-by-using-domain-name-label-scope/4093371.

The feature is disabled by default and can be enabled for AzureAppServiceEnvironment with method WithRegionalDnl().

Changes:

  • Added method WithRegionalDnl() to AzureAppServiceEnvironment.
  • This method sets property EnableRegionalDnl for the environment resource.
  • If true, it adds the following property to website resource:
    dashboard.AutoGeneratedDomainNameLabelScope = AutoGeneratedDomainNameLabelScope.TenantReuse
  • Since the hostname cannot be constructed (as it is random and generated by the platform), to specify dependencies between app services, we need to query the platform.
    • Added provisioning parameters to AppServiceWebsiteContext for website and slot host names
    • Added a pipeline step fetch-website-hostname that makes ARM call to endpoint /subscriptions/{armContext.SubscriptionId}/providers/Microsoft.Web/locations/{armContext.Location}/CheckNameAvailability to fetch the hostname. It sets the provisioning parameters.
    • The pipeline steps to fetch-website-hostname are executed before provisioning to resolve the dependencies.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 19, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14001

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14001"

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 19, 2026
@ShilpiRach ShilpiRach marked this pull request as ready for review January 23, 2026 05:33
Copilot AI review requested due to automatic review settings January 23, 2026 05:33
@ShilpiRach ShilpiRach marked this pull request as draft January 23, 2026 05:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for enabling regional Domain Name Label (DNL) for Azure App Service resources in the Aspire hosting model. Regional DNL allows Azure App Services to use region-specific hostnames with tenant reuse capabilities, providing more predictable and stable DNS names.

Changes:

  • Adds a new WithRegionalDNL() extension method to configure regional DNL for Azure App Service environments
  • Refactors hostname resolution to support both standard and regional DNL naming patterns
  • Introduces runtime hostname fetching via Azure ARM API calls to retrieve DNL-generated hostnames
  • Updates the provisioning pipeline to fetch and configure hostnames before provisioning resources

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
AzureAppServiceWebsiteContext.cs Refactored hostname handling to use provisioning parameters instead of computed Bicep values; added methods to get/set website hostnames
AzureAppServiceWebSiteResource.cs Added pipeline step to fetch DNL hostnames via ARM API; introduced new length constraints for DNL scenarios; refactored hostname construction logic
AzureAppServiceEnvironmentUtility.cs Updated dashboard creation to support regional DNL configuration with comprehensive XML documentation
AzureAppServiceEnvironmentResource.cs Added EnableRegionalDNL property and early return in PrintDashboardUrlAsync when dashboard is disabled
AzureAppServiceEnvironmentExtensions.cs Added public WithRegionalDNL API method; updated dashboard URI generation to use DefaultHostName

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/// <param name="builder">The AzureAppServiceEnvironmentResource to configure.</param>
/// <param name="enable">The regional DNL host name for all App Services in the App Service Environment.</param>
/// <returns><see cref="IResourceBuilder{T}"/></returns>
public static IResourceBuilder<AzureAppServiceEnvironmentResource> WithRegionalDNL(this IResourceBuilder<AzureAppServiceEnvironmentResource> builder, bool enable = true)
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The XML documentation for this method is missing required parameter descriptions, return value description, and sufficient detail for public API documentation. According to the coding guidelines, public APIs require comprehensive documentation including detailed remarks and parameter descriptions. The documentation should explain what DNL (Domain Name Label) is, when to use regional DNL, and what behavior changes when it's enabled.

Copilot generated this review using guidance from repository custom instructions.
var trimmedSlotName = TruncateToMaxLength(deploymentSlot, MaxDeploymentSlotNameLengthWithDnl);
websiteName += $"-{trimmedSlotName}";

return websiteName;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When regionalDnlEnabled is true and there's a deployment slot, the method returns the combined website name without applying a final length check (line 296). Unlike the non-DNL path which applies TruncateToMaxLength on the final combined string (line 308), the DNL path relies on the sum of pre-truncated parts. While the math appears correct (23 + 1 + 18 = 42), it would be more defensive and consistent with the non-DNL path to apply a final truncation to ensure the combined name never exceeds expected limits.

Suggested change
return websiteName;
return TruncateToMaxLength(websiteName, MaxWebsiteHostNameLengthWithSlotAndDnl);

Copilot uses AI. Check for mistakes.
ShilpiRach and others added 3 commits January 22, 2026 21:54
@ShilpiRach ShilpiRach changed the title [Testing] Add support to enable regional DNL for Azure App Service Add support to enable regional DNL for Azure App Service Feb 3, 2026
@ShilpiRach ShilpiRach marked this pull request as ready for review February 3, 2026 11:56
@eerhardt eerhardt self-assigned this Feb 4, 2026
@description('The location for the resource(s) to be deployed.')
param location string = resourceGroup().location

param container1websiteHostName string = '${take('${toLower('container1')}-${uniqueString(resourceGroup().id)}', 60)}.azurewebsites.net'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it so these parameters are not added if they aren't used?

Comment on lines +158 to +159
var fetchWebsiteHostNameSteps = context.GetSteps("fetch-website-hostname");
provisionSteps.DependsOn(fetchWebsiteHostNameSteps);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test that ensures when one app service references another app service that the steps are ordered correctly? From the code, I see that we are saying all app service provision steps depend on all other apps' fetch-website-hostname steps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we are saying all app service provision steps depend on all other apps' fetch-website-hostname steps.

Yes, this is needed to ensure that all hostnames are available before provisioning steps to resolve any references to other app services.


param project2_containerport string

param project1websiteHostName string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Who fills in this parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set by pipeline step that fetches hostname. It also has a default value for azd cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants