Skip to content

Commit dd29457

Browse files
authored
Refactor Azure Container Apps processing (#9075)
* Refactor Azure Container Apps processing - Split the 2 phases and state more clearly. The first pass is handled directly in before start and resolved environment variables, arguments, volumes, endpoints. - The second pass is during bicep writing where that data is processed and translated into the underlying bicep primitives. * Fixed tests again * Remove more whitespace * Update AzurePublishingContext tests to reflect new Bicep identifiers
1 parent 8239e2d commit dd29457

File tree

9 files changed

+284
-278
lines changed

9 files changed

+284
-278
lines changed

playground/AzureContainerApps/AzureContainerApps.AppHost/api.module.bicep

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
@description('The location for the resource(s) to be deployed.')
22
param location string = resourceGroup().location
33

4-
param api_identity_outputs_id string
4+
param infra_outputs_azure_container_apps_environment_default_domain string
55

6-
param api_identity_outputs_clientid string
6+
param infra_outputs_azure_container_apps_environment_id string
7+
8+
param infra_outputs_azure_container_registry_endpoint string
9+
10+
param infra_outputs_azure_container_registry_managed_identity_id string
11+
12+
param api_containerimage string
13+
14+
param api_identity_outputs_id string
715

816
param api_containerport string
917

@@ -19,15 +27,7 @@ param secretparam_value string
1927

2028
param api_identity_outputs_principalname string
2129

22-
param infra_outputs_azure_container_apps_environment_default_domain string
23-
24-
param infra_outputs_azure_container_apps_environment_id string
25-
26-
param infra_outputs_azure_container_registry_endpoint string
27-
28-
param infra_outputs_azure_container_registry_managed_identity_id string
29-
30-
param api_containerimage string
30+
param api_identity_outputs_clientid string
3131

3232
param certificateName string
3333

playground/AzureContainerApps/AzureContainerApps.AppHost/aspire-manifest.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
"type": "azure.bicep.v0",
4545
"path": "cache.module.bicep",
4646
"params": {
47-
"infra_outputs_volumes_cache_0": "{infra.outputs.volumes_cache_0}",
48-
"cache_password_value": "{cache-password.value}",
4947
"infra_outputs_azure_container_apps_environment_default_domain": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}",
50-
"infra_outputs_azure_container_apps_environment_id": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}"
48+
"infra_outputs_azure_container_apps_environment_id": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}",
49+
"cache_password_value": "{cache-password.value}",
50+
"infra_outputs_volumes_cache_0": "{infra.outputs.volumes_cache_0}"
5151
}
5252
},
5353
"entrypoint": "/bin/sh",
@@ -124,19 +124,19 @@
124124
"type": "azure.bicep.v0",
125125
"path": "api.module.bicep",
126126
"params": {
127+
"infra_outputs_azure_container_apps_environment_default_domain": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}",
128+
"infra_outputs_azure_container_apps_environment_id": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}",
129+
"infra_outputs_azure_container_registry_endpoint": "{infra.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}",
130+
"infra_outputs_azure_container_registry_managed_identity_id": "{infra.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}",
131+
"api_containerimage": "{api.containerImage}",
127132
"api_identity_outputs_id": "{api-identity.outputs.id}",
128-
"api_identity_outputs_clientid": "{api-identity.outputs.clientId}",
129133
"api_containerport": "{api.containerPort}",
130134
"storage_outputs_blobendpoint": "{storage.outputs.blobEndpoint}",
131135
"cache_password_value": "{cache-password.value}",
132136
"account_kv_outputs_name": "{account-kv.outputs.name}",
133137
"secretparam_value": "{secretparam.value}",
134138
"api_identity_outputs_principalname": "{api-identity.outputs.principalName}",
135-
"infra_outputs_azure_container_apps_environment_default_domain": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN}",
136-
"infra_outputs_azure_container_apps_environment_id": "{infra.outputs.AZURE_CONTAINER_APPS_ENVIRONMENT_ID}",
137-
"infra_outputs_azure_container_registry_endpoint": "{infra.outputs.AZURE_CONTAINER_REGISTRY_ENDPOINT}",
138-
"infra_outputs_azure_container_registry_managed_identity_id": "{infra.outputs.AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID}",
139-
"api_containerimage": "{api.containerImage}",
139+
"api_identity_outputs_clientid": "{api-identity.outputs.clientId}",
140140
"certificateName": "{certificateName.value}",
141141
"customDomain": "{customDomain.value}"
142142
}

playground/AzureContainerApps/AzureContainerApps.AppHost/cache.module.bicep

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
@description('The location for the resource(s) to be deployed.')
22
param location string = resourceGroup().location
33

4-
param infra_outputs_volumes_cache_0 string
4+
param infra_outputs_azure_container_apps_environment_default_domain string
5+
6+
param infra_outputs_azure_container_apps_environment_id string
57

68
@secure()
79
param cache_password_value string
810

9-
param infra_outputs_azure_container_apps_environment_default_domain string
10-
11-
param infra_outputs_azure_container_apps_environment_id string
11+
param infra_outputs_volumes_cache_0 string
1212

1313
resource cache 'Microsoft.App/containerApps@2024-03-01' = {
1414
name: 'cache'

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell
4242

4343
var containerAppEnvironmentContext = new ContainerAppEnvironmentContext(
4444
logger,
45+
executionContext,
4546
environment);
4647

4748
foreach (var r in appModel.Resources)
@@ -56,7 +57,7 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell
5657
continue;
5758
}
5859

59-
var containerApp = await containerAppEnvironmentContext.CreateContainerAppAsync(r, provisioningOptions.Value, executionContext, cancellationToken).ConfigureAwait(false);
60+
var containerApp = await containerAppEnvironmentContext.CreateContainerAppAsync(r, provisioningOptions.Value, cancellationToken).ConfigureAwait(false);
6061

6162
// Capture information about the container registry used by the
6263
// container app environment in the deployment target information

0 commit comments

Comments
 (0)