Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,13 @@ BicepValue<string> GetHostValue(string? prefix = null, string? suffix = null)
return (url, secretType);
}

if (value is ParameterResource param)
Copy link
Member

Choose a reason for hiding this comment

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

Consider a comment saying that it's important that this is resolved before connection strings.

But if a test catches a regression then not required.

{
var st = param.Secret ? SecretType.Normal : secretType;

return (AllocateParameter(param, secretType: st), st);
}

if (value is ConnectionStringReference cs)
{
return await ProcessValueAsync(cs.Resource.ConnectionStringExpression, executionContext, cancellationToken, secretType: secretType, parent: parent).ConfigureAwait(false);
Expand All @@ -644,13 +651,6 @@ BicepValue<string> GetHostValue(string? prefix = null, string? suffix = null)
return await ProcessValueAsync(csrs.ConnectionStringExpression, executionContext, cancellationToken, secretType: secretType, parent: parent).ConfigureAwait(false);
}

if (value is ParameterResource param)
{
var st = param.Secret ? SecretType.Normal : secretType;

return (AllocateParameter(param, secretType: st), st);
}

if (value is BicepOutputReference output)
{
return (AllocateParameter(output, secretType: secretType), secretType);
Expand Down
17 changes: 16 additions & 1 deletion tests/Aspire.Hosting.Azure.Tests/AzureContainerAppsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ public async Task ProjectWithManyReferenceTypes()
// Postgres uses secret outputs + a literal connection string
var pgdb = builder.AddAzurePostgresFlexibleServer("pg").WithPasswordAuthentication().AddDatabase("db");

var rawCs = builder.AddConnectionString("cs");

// Connection string (should be considered a secret)
var blob = builder.AddAzureStorage("storage").AddBlobs("blobs");

Expand All @@ -803,7 +805,8 @@ public async Task ProjectWithManyReferenceTypes()
.WithReference(pgdb)
.WithEnvironment("SecretVal", secretValue)
.WithEnvironment("secret_value_1", secretValue)
.WithEnvironment("Value", value);
.WithEnvironment("Value", value)
.WithEnvironment("CS", rawCs);

project.WithEnvironment(context =>
{
Expand Down Expand Up @@ -851,6 +854,7 @@ public async Task ProjectWithManyReferenceTypes()
"outputs_azure_container_registry_managed_identity_id": "{.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}",
"value0_value": "{value0.value}",
"value1_value": "{value1.value}",
"cs_connectionstring": "{cs.connectionString}",
"outputs_azure_container_apps_environment_default_domain": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}",
"outputs_managed_identity_client_id": "{.outputs.MANAGED_IDENTITY_CLIENT_ID}",
"outputs_azure_container_apps_environment_id": "{.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}",
Expand Down Expand Up @@ -882,6 +886,9 @@ param value0_value string

param value1_value string

@secure()
param cs_connectionstring string

param outputs_azure_container_apps_environment_default_domain string

param outputs_managed_identity_client_id string
Expand Down Expand Up @@ -920,6 +927,10 @@ param api_containerimage string
name: 'secret-value-1'
value: value0_value
}
{
name: 'cs'
value: cs_connectionstring
}
]
activeRevisionsMode: 'Single'
ingress: {
Expand Down Expand Up @@ -995,6 +1006,10 @@ param api_containerimage string
name: 'Value'
value: value1_value
}
{
name: 'CS'
secretRef: 'cs'
}
{
name: 'HTTP_EP'
value: 'http://api.internal.${outputs_azure_container_apps_environment_default_domain}'
Expand Down