Skip to content

Update Azure.Provisioning.Cdn to 1.0.0-beta.2 - #16986

Merged
Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt/update-azure-provisioning-cdn
May 14, 2026
Merged

Eric Erhardt (eerhardt) merged 1 commit into
mainfrom
eerhardt/update-azure-provisioning-cdn

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Description

With the latest version we can remove our own name generation and length limit and instead rely on the base Azure.Provisioning algorithm to generate names.

NOTE: This is a change from the 13.3.0-preview version and can result in duplicate endpoints, origin groups, routes. etc. Remove the existing resource, or set the Name explicitly in ConfigureInfrastructure, to avoid it during the upgrade.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No

With the latest version we can remove our own name generation and length limit and instead rely on the base Azure.Provisioning algorithm to generate names.

NOTE: This is a change from the 13.3.0-preview version and can result in duplicate endpoints, origin groups, routes. etc. Remove the existing resource, or set the Name explicitly in ConfigureInfrastructure, to avoid it during the upgrade.
@github-actions

Copy link
Copy Markdown
Contributor

🚀 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16986

Or

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates Azure Front Door provisioning to use Azure.Provisioning.Cdn 1.0.0-beta.2 and relies on the provisioning library’s built-in name generation (instead of Aspire-maintained name generation/length caps), with snapshot updates to match the new emitted Bicep.

Changes:

  • Bump Azure.Provisioning.Cdn to 1.0.0-beta.2 (and update pinned Azure.Core).
  • Remove explicit Name = ... assignments for Front Door profile/endpoint/origin group/origin/route resources.
  • Update Azure Front Door Bicep snapshots to reflect the new name generation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Aspire.Hosting.Azure.FrontDoor/AzureFrontDoorExtensions.cs Removes explicit resource name generation and relies on Azure.Provisioning defaults.
Directory.Packages.props Updates Azure.Provisioning.Cdn to beta.2 and bumps pinned Azure.Core.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureFrontDoorTests.AddAzureFrontDoorWithSingleOriginGeneratesBicep.verified.bicep Updates expected Bicep output for the new naming algorithm.
tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureFrontDoorTests.AddAzureFrontDoorWithMultipleOriginsGeneratesBicep.verified.bicep Updates expected Bicep output for the new naming algorithm.
Comments suppressed due to low confidence (1)

src/Aspire.Hosting.Azure.FrontDoor/AzureFrontDoorExtensions.cs:139

  • Azure naming rules list Microsoft.Cdn profiles / afdEndpoints / routes as max length 50. With Name now left to the Provisioning default generation, route names based on originBicepId could exceed that limit for long origin names, leading to deployment failures. Consider enforcing the 50-char limit for generated route names (or confirm Azure.Provisioning.Cdn applies the correct limit).
                var route = new FrontDoorRoute($"{originBicepId}Route")
                {
                    Parent = endpoint,
                    OriginGroupId = originGroup.Id,
                    PatternsToMatch = ["/*"],
                    ForwardingProtocol = ForwardingProtocol.HttpsOnly,
                    LinkToDefaultDomain = LinkToDefaultDomain.Enabled,
                    HttpsRedirect = HttpsRedirect.Enabled
                };

@github-actions

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 78 recordings uploaded (commit fe7de58)

View all recordings
Status Test Recording
❔ AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
❔ AddPackageWhileAppHostRunningDetached ▶️ View Recording
❔ AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
❔ AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
❔ AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
❔ AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
❔ AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View Recording
❔ AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
❔ Banner_DisplayedOnFirstRun ▶️ View Recording
❔ Banner_DisplayedWithExplicitFlag ▶️ View Recording
❔ Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
❔ CertificatesClean_RemovesCertificates ▶️ View Recording
❔ CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
❔ CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
❔ ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
❔ CreateAndRunAspireStarterProject ▶️ View Recording
❔ CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
❔ CreateAndRunEmptyAppHostProject ▶️ View Recording
❔ CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
❔ CreateAndRunJsReactProject ▶️ View Recording
❔ CreateAndRunPythonReactProject ▶️ View Recording
❔ CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
❔ CreateAndRunTypeScriptStarterProject ▶️ View Recording
❔ CreateJavaAppHostWithViteApp ▶️ View Recording
❔ CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
❔ DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
❔ DeployK8sBasicApiService ▶️ View Recording
❔ DeployK8sWithExternalHelmChart ▶️ View Recording
❔ DeployK8sWithGarnet ▶️ View Recording
❔ DeployK8sWithMongoDB ▶️ View Recording
❔ DeployK8sWithMySql ▶️ View Recording
❔ DeployK8sWithPostgres ▶️ View Recording
❔ DeployK8sWithRabbitMQ ▶️ View Recording
❔ DeployK8sWithRedis ▶️ View Recording
❔ DeployK8sWithSqlServer ▶️ View Recording
❔ DeployK8sWithValkey ▶️ View Recording
❔ DeployTypeScriptAppToKubernetes ▶️ View Recording
❔ DescribeCommandResolvesReplicaNames ▶️ View Recording
❔ DescribeCommandShowsRunningResources ▶️ View Recording
❔ DetachFormatJsonProducesValidJson ▶️ View Recording
❔ DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
❔ DoListStepsShowsPipelineSteps ▶️ View Recording
❔ DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
❔ DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
❔ DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View Recording
❔ DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
❔ DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
❔ GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
❔ GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
❔ GlobalMigration_PreservesAllValueTypes ▶️ View Recording
❔ GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
❔ GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
❔ InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
❔ InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
❔ InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
❔ LatestCliCanStartStableChannelAppHost ▶️ View Recording
❔ LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View Recording
❔ LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
❔ LogsCommandShowsResourceLogs ▶️ View Recording
❔ OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
❔ PsCommandListsRunningAppHost ▶️ View Recording
❔ PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
❔ PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
❔ PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
❔ PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
❔ RestoreGeneratesSdkFiles ▶️ View Recording
❔ RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
❔ RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
❔ RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
❔ RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
❔ SecretCrudOnDotNetAppHost ▶️ View Recording
❔ SecretCrudOnTypeScriptAppHost ▶️ View Recording
❔ StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
❔ StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
❔ StopAllAppHostsFromAppHostDirectory ▶️ View Recording
❔ StopNonInteractiveSingleAppHost ▶️ View Recording
❔ StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
❔ UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25759683605

@eerhardt

Copy link
Copy Markdown
Member Author

If anyone was using Azure Front Door in 13.3 and wants the same names produced, they can use the following code:

In your AppHost's Main add the following line:

builder.Services.Configure<AzureProvisioningOptions>(options =>
{
    options.ProvisioningBuildOptions.InfrastructureResolvers.Insert(
        0, new AzureFrontDoorResourceNamePropertyResolver());
});

And then add the following class:

#pragma warning disable AZPROVISION001 // Type is for evaluation purposes only and is subject to change or removal in future updates.

using Azure.Provisioning;
using Azure.Provisioning.Cdn;
using Azure.Provisioning.Expressions;
using Azure.Provisioning.Primitives;

namespace Aspire.Hosting.Azure;

/// <summary>
/// Uses the first preview's Azure Front Door naming scheme to provide default names for CDN resources.
/// </summary>
public sealed class AzureFrontDoorResourceNamePropertyResolver : DynamicResourceNamePropertyResolver
{
    private const int ProfileNameMaxLength = 90;
    private const int EndpointNameMaxLength = 46;
    private const int OriginGroupNameMaxLength = 90;
    private const int OriginNameMaxLength = 90;
    private const int RouteNameMaxLength = 90;

    /// <inheritdoc/>
    public override BicepValue<string>? ResolveName(
        ProvisioningBuildOptions options,
        ProvisionableResource resource,
        ResourceNameRequirements requirements)
    {
        var suffix = GetUniqueSuffix(options, resource);

        if (resource is CdnProfile)
        {
            var prefix = GetAspireResourceName(resource);
            return BicepFunction.Take(
                BicepFunction.Interpolate($"{prefix}-{suffix}"),
                ProfileNameMaxLength);
        }

        if (resource is FrontDoorEndpoint)
        {
            var originName = GetOriginName(resource, "Endpoint");
            return BicepFunction.Take(
                BicepFunction.Interpolate($"{originName}-{suffix}"),
                EndpointNameMaxLength);
        }

        if (resource is FrontDoorOriginGroup)
        {
            var originName = GetOriginName(resource, "OriginGroup");
            return BicepFunction.Take(
                BicepFunction.Interpolate($"{originName}-og-{suffix}"),
                OriginGroupNameMaxLength);
        }

        if (resource is FrontDoorOrigin)
        {
            var originName = GetOriginName(resource, "Origin");
            return BicepFunction.Take(
                BicepFunction.Interpolate($"{originName}-origin-{suffix}"),
                OriginNameMaxLength);
        }

        if (resource is FrontDoorRoute)
        {
            var originName = GetOriginName(resource, "Route");
            return BicepFunction.Take(
                BicepFunction.Interpolate($"{originName}-route-{suffix}"),
                RouteNameMaxLength);
        }

        // Non-CDN resources are handled by other resolvers in the chain.
        return null;
    }

    private static string GetAspireResourceName(ProvisionableResource resource)
    {
        if (resource.ProvisionableProperties.TryGetValue("Tags", out var tags) &&
            tags is BicepDictionary<string> tagDictionary &&
            tagDictionary.TryGetValue("aspire-resource-name", out var aspireResourceName) &&
            aspireResourceName?.Value is not null)
        {
            return aspireResourceName.Value;
        }

        return resource.BicepIdentifier;
    }

    /// <summary>
    /// Extracts the origin name from a child resource's BicepIdentifier by stripping the known
    /// suffix and converting back to the lowercased, hyphenated form used by the original naming.
    /// </summary>
    /// <remarks>
    /// The BicepIdentifier is constructed as <c>{originBicepId}{suffix}</c> where originBicepId
    /// is the normalized form of the origin resource name (hyphens replaced with underscores).
    /// For example, "my-api" becomes "my_api", so "my_apiEndpoint" → strip "Endpoint" → "my_api"
    /// → replace underscores → "my-api".
    /// </remarks>
    private static string GetOriginName(ProvisionableResource resource, string suffixToStrip)
    {
        var bicepId = resource.BicepIdentifier;

        if (bicepId.EndsWith(suffixToStrip, StringComparison.Ordinal))
        {
            bicepId = bicepId[..^suffixToStrip.Length];
        }

        // Convert underscores back to hyphens and lowercase to match the original naming
        // scheme, which used originResource.Name.ToLowerInvariant() directly.
        return bicepId.Replace('_', '-').ToLowerInvariant();
    }
}

@eerhardt
Eric Erhardt (eerhardt) merged commit 0f10cfa into main May 14, 2026
580 of 583 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 14, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #965

Generated by PR Documentation Check

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#965 targeting release/13.4.

Updated src/frontend/src/content/docs/integrations/cloud/azure/azure-front-door.mdx to reflect the new Azure Front Door resource naming introduced in .NET Aspire 13.4 (via Azure.Provisioning.Cdn 1.0.0-beta.2). The generated Bicep snippet now shows the updated names (e.g., myapiEndpoint, myapiOriginGroup, myapiOrigin, myapiRoute) and the increased profile name length limit (260 vs. 90). A caution note was also added warning users upgrading from 13.3.0-preview that the naming change can produce duplicate Azure resources, with guidance to either remove existing resources or set names explicitly via ConfigureInfrastructure.

Note

This draft PR needs human review before merging.

Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
With the latest version we can remove our own name generation and length limit and instead rely on the base Azure.Provisioning algorithm to generate names.

NOTE: This is a change from the 13.3.0-preview version and can result in duplicate endpoints, origin groups, routes. etc. Remove the existing resource, or set the Name explicitly in ConfigureInfrastructure, to avoid it during the upgrade.
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants