-
Notifications
You must be signed in to change notification settings - Fork 816
Closed
Labels
area-integrationsIssues pertaining to Aspire Integrations packagesIssues pertaining to Aspire Integrations packagesazureIssues associated specifically with scenarios tied to using AzureIssues associated specifically with scenarios tied to using Azure‼️regression-from-last-releaseThis used to work in an earlier version of Aspire and we broke it!This used to work in an earlier version of Aspire and we broke it!
Milestone
Description
Using an AzureBicepResource with a template file and using AzurePublishingContext to publish all the bicep files, results in an exception:
12:59:32 (publish-custom) ✗ Failed to write Azure Bicep templates: Could not find file
'C:\Users\eerhardt\AppData\Local\Temp\aspire-bicepwqooyya3.vit\front-door-appservice.bicep'. (0.0s)
12:59:32 (publish-custom) ✗ [ERR] Failed to write Azure Bicep templates to
C:\Users\eerhardt\source\repos\AspireApp4\AspireApp4.AppHost\aspire-output\root\templates
12:59:32 (publish-custom) ✗ [ERR] Step 'publish-custom' failed.
12:59:32 (publish-custom) ✗ Step 'publish-custom' failed: Could not find file
'C:\Users\eerhardt\AppData\Local\Temp\aspire-bicepwqooyya3.vit\front-door-appservice.bicep'.
12:59:32 (pipeline-execution) ✗ [ERR] Step 'publish-custom' failed: Could not find file
'C:\Users\eerhardt\AppData\Local\Temp\aspire-bicepwqooyya3.vit\front-door-appservice.bicep'.
12:59:32 (pipeline-execution) ✗ Failed
Repo steps
aspire do pubilsh-custom the following AppHost:
#pragma warning disable ASPIREPIPELINES001
#pragma warning disable ASPIREPIPELINES004
#pragma warning disable ASPIREAZURE001
using Aspire.Hosting.Azure;
using Aspire.Hosting.Pipelines;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
var builder = DistributedApplication.CreateBuilder(args);
var apiService = builder.AddProject<Projects.AspireApp4_ApiService>("apiservice")
.WithHttpHealthCheck("/health");
var frontend = builder.AddProject<Projects.AspireApp4_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithHttpHealthCheck("/health")
.WithReference(apiService)
.WaitFor(apiService);
builder.AddAzureFrontDoor("afd", frontend);
builder.Pipeline.AddStep("publish-custom", async context =>
{
var outputPath = Path.Combine(context.Services.GetRequiredService<IPipelineOutputService>().GetOutputDirectory(), "root");
var outputDirectory = new DirectoryInfo(outputPath);
outputDirectory.Create();
var templates = new DirectoryInfo(Path.Join(outputDirectory.FullName, "templates"));
templates.Create();
var azureProvisioningOptions = context.Services.GetRequiredService<IOptions<AzureProvisioningOptions>>().Value;
var azPublishContext = new AzurePublishingContext(templates.FullName, azureProvisioningOptions, context.Services, context.Logger, context.ReportingStep);
var azureEnvironmentResource = context.Model.Resources.OfType<AzureEnvironmentResource>().FirstOrDefault() ?? throw new InvalidOperationException("AzureEnvironmentResource not found in the model.");
await azPublishContext.WriteModelAsync(context.Model, azureEnvironmentResource, context.CancellationToken).ConfigureAwait(false);
});
builder.Build().Run();
internal static class DeploymentExtensions
{
public static IResourceBuilder<AzureBicepResource> AddAzureFrontDoor(
this IDistributedApplicationBuilder builder,
[ResourceName] string name,
IResourceBuilder<ProjectResource> appServiceWebsite)
{
builder.AddAzureProvisioning();
var frontDoorName = $"{name}-afd";
var frontdoor = new AzureBicepResource(frontDoorName, "front-door-appservice.bicep");
return builder.AddResource(frontdoor)
.WithParameter("frontDoorName", frontDoorName)
.WithParameter("appServiceHostName", appServiceWebsite.Resource.Name);
}
}with front-door-appservice.bicep:
param frontDoorName string
param appServiceHostName string
@description('Location for all resources, needed because Aspire always injects a location parameter')
param location string = resourceGroup().location
resource frontDoorProfile 'Microsoft.Cdn/profiles@2024-02-01' = {
name: take('${frontDoorName}${uniqueString(resourceGroup().id)}', 50)
location: 'Global'
sku: {
name: 'Premium_AzureFrontDoor'
}
}
resource frontDoorEndpoint 'Microsoft.Cdn/profiles/afdEndpoints@2025-06-01' = {
parent: frontDoorProfile
name: take('${frontDoorName}-endp-${uniqueString(resourceGroup().id)}', 50)
location: 'Global'
properties: {
enabledState: 'Enabled'
}
}
resource originGroup 'Microsoft.Cdn/profiles/originGroups@2025-06-01' = {
parent: frontDoorProfile
name: take('appservice-origin-group-${uniqueString(resourceGroup().id)}', 50)
properties: {
loadBalancingSettings: {
sampleSize: 4
successfulSamplesRequired: 3
additionalLatencyInMilliseconds: 50
}
healthProbeSettings: {
probePath: '/'
probeRequestType: 'HEAD'
probeProtocol: 'Https'
probeIntervalInSeconds: 240
}
sessionAffinityState: 'Disabled'
}
}
resource origin 'Microsoft.Cdn/profiles/originGroups/origins@2025-06-01' = {
parent: originGroup
name: take('appservice-origin-${uniqueString(resourceGroup().id)}', 50)
properties: {
hostName: take('${appServiceHostName}-${uniqueString(resourceGroup().id)}.azurewebsites.net', 50)
httpPort: 80
httpsPort: 443
originHostHeader: take('${appServiceHostName}-${uniqueString(resourceGroup().id)}.azurewebsites.net', 50)
priority: 1
weight: 1000
enabledState: 'Enabled'
enforceCertificateNameCheck: true
}
}
resource route 'Microsoft.Cdn/profiles/afdEndpoints/routes@2025-06-01' = {
parent: frontDoorEndpoint
name: take('default-route-${uniqueString(resourceGroup().id)}', 50)
dependsOn: [
origin
]
properties: {
cacheConfiguration: {
compressionSettings: {
isCompressionEnabled: true
contentTypesToCompress: [
'text/plain'
'text/html'
'text/css'
'application/javascript'
'application/json'
'image/svg+xml'
]
}
queryStringCachingBehavior: 'IgnoreQueryString'
}
originGroup: {
id: originGroup.id
}
supportedProtocols: [
'Http'
'Https'
]
patternsToMatch: [
'/*'
]
forwardingProtocol: 'HttpsOnly'
linkToDefaultDomain: 'Enabled'
httpsRedirect: 'Enabled'
enabledState: 'Enabled'
originPath: '/'
ruleSets: []
}
}
output endpointUrl string = 'https://${frontDoorEndpoint.properties.hostName}'This should pass successfully. It worked before Aspire 13.1. I believe the change that caused this issue was: 5b92c02#diff-86b4ae887912c3dbe34b3c97beb99e9b12272fd077b7b57e675818b0a83205b5
Reactions are currently unavailable
Metadata
Metadata
Labels
area-integrationsIssues pertaining to Aspire Integrations packagesIssues pertaining to Aspire Integrations packagesazureIssues associated specifically with scenarios tied to using AzureIssues associated specifically with scenarios tied to using Azure‼️regression-from-last-releaseThis used to work in an earlier version of Aspire and we broke it!This used to work in an earlier version of Aspire and we broke it!