Skip to content

Commit 22a4ed5

Browse files
authored
Bump the priority of processing parameters to avoid infinite recursion (#7588)
- Added test
1 parent d25bb1f commit 22a4ed5

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/Aspire.Hosting.Azure.AppContainers/AzureContainerAppsInfrastructure.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,13 @@ BicepValue<string> GetHostValue(string? prefix = null, string? suffix = null)
634634
return (url, secretType);
635635
}
636636

637+
if (value is ParameterResource param)
638+
{
639+
var st = param.Secret ? SecretType.Normal : secretType;
640+
641+
return (AllocateParameter(param, secretType: st), st);
642+
}
643+
637644
if (value is ConnectionStringReference cs)
638645
{
639646
return await ProcessValueAsync(cs.Resource.ConnectionStringExpression, executionContext, cancellationToken, secretType: secretType, parent: parent).ConfigureAwait(false);
@@ -644,13 +651,6 @@ BicepValue<string> GetHostValue(string? prefix = null, string? suffix = null)
644651
return await ProcessValueAsync(csrs.ConnectionStringExpression, executionContext, cancellationToken, secretType: secretType, parent: parent).ConfigureAwait(false);
645652
}
646653

647-
if (value is ParameterResource param)
648-
{
649-
var st = param.Secret ? SecretType.Normal : secretType;
650-
651-
return (AllocateParameter(param, secretType: st), st);
652-
}
653-
654654
if (value is BicepOutputReference output)
655655
{
656656
return (AllocateParameter(output, secretType: secretType), secretType);

tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@ public async Task ProjectWithManyReferenceTypes()
785785
// Postgres uses secret outputs + a literal connection string
786786
var pgdb = builder.AddAzurePostgresFlexibleServer("pg").WithPasswordAuthentication().AddDatabase("db");
787787

788+
var rawCs = builder.AddConnectionString("cs");
789+
788790
// Connection string (should be considered a secret)
789791
var blob = builder.AddAzureStorage("storage").AddBlobs("blobs");
790792

@@ -803,7 +805,8 @@ public async Task ProjectWithManyReferenceTypes()
803805
.WithReference(pgdb)
804806
.WithEnvironment("SecretVal", secretValue)
805807
.WithEnvironment("secret_value_1", secretValue)
806-
.WithEnvironment("Value", value);
808+
.WithEnvironment("Value", value)
809+
.WithEnvironment("CS", rawCs);
807810

808811
project.WithEnvironment(context =>
809812
{
@@ -851,6 +854,7 @@ public async Task ProjectWithManyReferenceTypes()
851854
"outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}",
852855
"value0_value": "{value0.value}",
853856
"value1_value": "{value1.value}",
857+
"cs_connectionstring": "{cs.connectionString}",
854858
"outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}",
855859
"outputs_managed_identity_client_id": "{.outputs.MANAGED_IDENTITY_CLIENT_ID}",
856860
"outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}",
@@ -882,6 +886,9 @@ param value0_value string
882886
883887
param value1_value string
884888
889+
@secure()
890+
param cs_connectionstring string
891+
885892
param outputs_azure_container_apps_environment_default_domain string
886893
887894
param outputs_managed_identity_client_id string
@@ -920,6 +927,10 @@ param api_containerimage string
920927
name: 'secret-value-1'
921928
value: value0_value
922929
}
930+
{
931+
name: 'cs'
932+
value: cs_connectionstring
933+
}
923934
]
924935
activeRevisionsMode: 'Single'
925936
ingress: {
@@ -995,6 +1006,10 @@ param api_containerimage string
9951006
name: 'Value'
9961007
value: value1_value
9971008
}
1009+
{
1010+
name: 'CS'
1011+
secretRef: 'cs'
1012+
}
9981013
{
9991014
name: 'HTTP_EP'
10001015
value: 'http://api.internal.${outputs_azure_container_apps_environment_default_domain}'

0 commit comments

Comments
 (0)