-
Notifications
You must be signed in to change notification settings - Fork 695
Description
When users need to configure their bicep, one way to do it across all resources is to configure the AzureProvisioningOptions
and tweak the ProvisioningBuildOptions
to provide InfrastructureResolvers
.
Configuring these options when using PublishAsAzureContainerApp
isn't working because the following code isn't setting the ProvisioningBuildOptions
on the AzureProvisioningResource
.
aspire/src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppsInfrastructure.cs
Lines 82 to 86 in 4febb16
var provisioningResource = new AzureProvisioningResource(resource.Name, context.BuildContainerApp); | |
provisioningResource.Annotations.Add(new ManifestPublishingCallbackAnnotation(provisioningResource.WriteToManifest)); | |
return provisioningResource; |
Repro Steps
Publish the manifest/bicep for the following:
var builder = DistributedApplication.CreateBuilder(args);
builder.Services.Configure<AzureProvisioningOptions>(options => options.ProvisioningBuildOptions.InfrastructureResolvers.Insert(0, new MyResourceNamePropertyResolver()));
builder.AddProject<Projects.AzureContainerApps_ApiService>("api")
.WithExternalHttpEndpoints()
.PublishAsAzureContainerApp((module, app) =>
{
// Scale to 0
app.Template.Scale.MinReplicas = 0;
});
builder.Build().Run();
public sealed class MyResourceNamePropertyResolver : DynamicResourceNamePropertyResolver
{
public override void ResolveProperties(ProvisionableConstruct construct, ProvisioningBuildOptions options)
{
if (construct is ContainerApp app)
{
app.Name = "myContainerAppName";
}
base.ResolveProperties(construct, options);
}
}
Expected results
The MyResourceNamePropertyResolver
should have been used to give the api
ContainerApp an Azure name of "myContainerAppName"
.
Actual results
The MyResourceNamePropertyResolver
is not used and instead it gets:
resource api 'Microsoft.App/containerApps@2024-03-01' = {
name: 'api'