Repository navigation
Update Azure.Provisioning.Cdn to 1.0.0-beta.2 - #16986
Conversation
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.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16986Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16986" |
There was a problem hiding this comment.
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.Cdnto1.0.0-beta.2(and update pinnedAzure.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 / routesas max length 50. With Name now left to the Provisioning default generation, route names based onoriginBicepIdcould 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
};
|
🎬 CLI E2E Test Recordings — 78 recordings uploaded (commit View all recordings
📹 Recordings uploaded automatically from CI run #25759683605 |
|
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();
}
} |
|
Pull request created: #965
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#965 targeting Updated Note This draft PR needs human review before merging. |
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.
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