Skip to content

Commit 5b42552

Browse files
Merge pull request #1128 from microsoft/bugfix/avm-deployment-dev
fix: avm+waf deployment
2 parents d346464 + 4f82baa commit 5b42552

7 files changed

Lines changed: 246 additions & 173 deletions

File tree

infra/avm/main.bicep

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ var supportedModels = [
323323
]
324324

325325
var containerAppName = 'ca-${solutionSuffix}'
326+
var backendUsesBootstrapImage = toLower(backendContainerRegistryHostname) == 'mcr.microsoft.com' && toLower(backendContainerImageName) == 'azuredocs/containerapps-helloworld'
327+
var mcpUsesBootstrapImage = toLower(MCPContainerRegistryHostname) == 'mcr.microsoft.com' && toLower(MCPContainerImageName) == 'azuredocs/containerapps-helloworld'
326328

327329
var privateDnsZones = [
328330
'privatelink.cognitiveservices.azure.com'
@@ -1069,18 +1071,20 @@ module containerApp './modules/compute/container-app.bicep' = {
10691071
tags: tags
10701072
environmentResourceId: containerAppEnvironment.outputs.resourceId
10711073
ingressExternal: true
1072-
ingressTargetPort: 8000
1074+
ingressTargetPort: backendUsesBootstrapImage ? 80 : 8000
10731075
ingressAllowInsecure: false
10741076
enableTelemetry: enableTelemetry
10751077
managedIdentities: {
10761078
userAssignedResourceIds: [managed_identity.outputs.resourceId]
10771079
}
1078-
registries: [
1079-
{
1080-
server: acrLoginServer
1081-
identity: managed_identity.outputs.resourceId
1082-
}
1083-
]
1080+
registries: backendUsesBootstrapImage
1081+
? null
1082+
: [
1083+
{
1084+
server: acrLoginServer
1085+
identity: managed_identity.outputs.resourceId
1086+
}
1087+
]
10841088
corsPolicy: {
10851089
allowedOrigins: [
10861090
'https://app-${solutionSuffix}.azurewebsites.net'
@@ -1246,18 +1250,20 @@ module containerAppMcp './modules/compute/container-app.bicep' = {
12461250
tags: tags
12471251
environmentResourceId: containerAppEnvironment.outputs.resourceId
12481252
ingressExternal: true
1249-
ingressTargetPort: 9000
1253+
ingressTargetPort: mcpUsesBootstrapImage ? 80 : 9000
12501254
ingressAllowInsecure: false
12511255
enableTelemetry: enableTelemetry
12521256
managedIdentities: {
12531257
userAssignedResourceIds: [managed_identity.outputs.resourceId]
12541258
}
1255-
registries: [
1256-
{
1257-
server: acrLoginServer
1258-
identity: managed_identity.outputs.resourceId
1259-
}
1260-
]
1259+
registries: mcpUsesBootstrapImage
1260+
? null
1261+
: [
1262+
{
1263+
server: acrLoginServer
1264+
identity: managed_identity.outputs.resourceId
1265+
}
1266+
]
12611267
corsPolicy: {
12621268
allowedOrigins: [
12631269
'https://app-${solutionSuffix}.azurewebsites.net'

infra/avm/main.json

Lines changed: 60 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.44.1.10279",
9-
"templateHash": "10080544909430391861"
9+
"templateHash": "15518088603134439540"
1010
},
1111
"name": "Multi-Agent Custom Automation Engine - AVM",
1212
"description": "AVM orchestrator for the Multi-Agent Custom Automation Engine accelerator. Deploys the same logical resources and preserves the same outputs as infra\\main.bicep using local AVM wrapper modules."
@@ -467,6 +467,8 @@
467467
"[parameters('gptImageModelName')]"
468468
],
469469
"containerAppName": "[format('ca-{0}', variables('solutionSuffix'))]",
470+
"backendUsesBootstrapImage": "[and(equals(toLower(parameters('backendContainerRegistryHostname')), 'mcr.microsoft.com'), equals(toLower(parameters('backendContainerImageName')), 'azuredocs/containerapps-helloworld'))]",
471+
"mcpUsesBootstrapImage": "[and(equals(toLower(parameters('MCPContainerRegistryHostname')), 'mcr.microsoft.com'), equals(toLower(parameters('MCPContainerImageName')), 'azuredocs/containerapps-helloworld'))]",
470472
"privateDnsZones": [
471473
"privatelink.cognitiveservices.azure.com",
472474
"privatelink.openai.azure.com",
@@ -687,7 +689,7 @@
687689
"aiSearchIndexNameForRFPSummary": "macae-rfp-summary-index",
688690
"aiSearchIndexNameForRFPRisk": "macae-rfp-risk-index",
689691
"aiSearchIndexNameForRFPCompliance": "macae-rfp-compliance-index",
690-
"virtualMachineAvailabilityZone": 1,
692+
"virtualMachineAvailabilityZone": -1,
691693
"aiFoundryOpenAIEndpoint": "[format('https://{0}.openai.azure.com/', variables('aiFoundryAiServicesResourceName'))]"
692694
},
693695
"resources": {
@@ -28583,7 +28585,7 @@
2858328585
"_generator": {
2858428586
"name": "bicep",
2858528587
"version": "0.44.1.10279",
28586-
"templateHash": "10180502016624897684"
28588+
"templateHash": "13733831222630151234"
2858728589
}
2858828590
},
2858928591
"parameters": {
@@ -28609,7 +28611,7 @@
2860928611
"modelName": {
2861028612
"type": "string",
2861128613
"metadata": {
28612-
"description": "Required. Model name (e.g., gpt-4o, text-embedding-ada-002)."
28614+
"description": "Required. Model name (e.g., gpt-5.4-mini, text-embedding-ada-002)."
2861328615
}
2861428616
},
2861528617
"modelVersion": {
@@ -54859,9 +54861,7 @@
5485954861
"ingressExternal": {
5486054862
"value": true
5486154863
},
54862-
"ingressTargetPort": {
54863-
"value": 8000
54864-
},
54864+
"ingressTargetPort": "[if(variables('backendUsesBootstrapImage'), createObject('value', 80), createObject('value', 8000))]",
5486554865
"ingressAllowInsecure": {
5486654866
"value": false
5486754867
},
@@ -54875,14 +54875,7 @@
5487554875
]
5487654876
}
5487754877
},
54878-
"registries": {
54879-
"value": [
54880-
{
54881-
"server": "[if(variables('useExistingContainerRegistry'), format('{0}.azurecr.io', variables('existingContainerRegistryName')), reference('container_registry').outputs.loginServer.value)]",
54882-
"identity": "[reference('managed_identity').outputs.resourceId.value]"
54883-
}
54884-
]
54885-
},
54878+
"registries": "[if(variables('backendUsesBootstrapImage'), createObject('value', null()), createObject('value', createArray(createObject('server', if(variables('useExistingContainerRegistry'), format('{0}.azurecr.io', variables('existingContainerRegistryName')), reference('container_registry').outputs.loginServer.value), 'identity', reference('managed_identity').outputs.resourceId.value))))]",
5488654879
"corsPolicy": {
5488754880
"value": {
5488854881
"allowedOrigins": [
@@ -56862,9 +56855,7 @@
5686256855
"ingressExternal": {
5686356856
"value": true
5686456857
},
56865-
"ingressTargetPort": {
56866-
"value": 9000
56867-
},
56858+
"ingressTargetPort": "[if(variables('mcpUsesBootstrapImage'), createObject('value', 80), createObject('value', 9000))]",
5686856859
"ingressAllowInsecure": {
5686956860
"value": false
5687056861
},
@@ -56878,14 +56869,7 @@
5687856869
]
5687956870
}
5688056871
},
56881-
"registries": {
56882-
"value": [
56883-
{
56884-
"server": "[if(variables('useExistingContainerRegistry'), format('{0}.azurecr.io', variables('existingContainerRegistryName')), reference('container_registry').outputs.loginServer.value)]",
56885-
"identity": "[reference('managed_identity').outputs.resourceId.value]"
56886-
}
56887-
]
56888-
},
56872+
"registries": "[if(variables('mcpUsesBootstrapImage'), createObject('value', null()), createObject('value', createArray(createObject('server', if(variables('useExistingContainerRegistry'), format('{0}.azurecr.io', variables('existingContainerRegistryName')), reference('container_registry').outputs.loginServer.value), 'identity', reference('managed_identity').outputs.resourceId.value))))]",
5688956873
"corsPolicy": {
5689056874
"value": {
5689156875
"allowedOrigins": [
@@ -56966,10 +56950,18 @@
5696656950
"name": "AZURE_OPENAI_IMAGE_DEPLOYMENT",
5696756951
"value": "[parameters('gptImageModelName')]"
5696856952
},
56953+
{
56954+
"name": "AZURE_OPENAI_IMAGE_QUALITY",
56955+
"value": "high"
56956+
},
5696956957
{
5697056958
"name": "AZURE_STORAGE_BLOB_URL",
5697156959
"value": "[reference('storage_account').outputs.blobEndpoint.value]"
5697256960
},
56961+
{
56962+
"name": "AZURE_STORAGE_IMAGES_CONTAINER",
56963+
"value": "generated-images"
56964+
},
5697356965
{
5697456966
"name": "BACKEND_URL",
5697556967
"value": "[format('https://{0}.{1}', variables('containerAppName'), reference('containerAppEnvironment').outputs.defaultDomain.value)]"
@@ -59690,14 +59682,19 @@
5969059682
"value": {
5969159683
"SCM_DO_BUILD_DURING_DEPLOYMENT": "true",
5969259684
"DOCKER_REGISTRY_SERVER_URL": "[format('https://{0}', if(variables('useExistingContainerRegistry'), format('{0}.azurecr.io', variables('existingContainerRegistryName')), reference('container_registry').outputs.loginServer.value))]",
59693-
"WEBSITES_PORT": "3000",
5969459685
"WEBSITES_CONTAINER_START_TIME_LIMIT": "1800",
5969559686
"BACKEND_API_URL": "[format('https://{0}', reference('containerApp').outputs.fqdn.value)]",
5969659687
"AUTH_ENABLED": "false",
5969759688
"PROXY_API_REQUESTS": "[if(parameters('enablePrivateNetworking'), 'true', 'false')]"
5969859689
}
5969959690
},
5970059691
"virtualNetworkSubnetId": "[if(parameters('enablePrivateNetworking'), createObject('value', reference('virtualNetwork').outputs.webserverfarmSubnetResourceId.value), createObject('value', ''))]",
59692+
"vnetRouteAllEnabled": {
59693+
"value": "[parameters('enablePrivateNetworking')]"
59694+
},
59695+
"imagePullTraffic": {
59696+
"value": "[parameters('enablePrivateNetworking')]"
59697+
},
5970159698
"publicNetworkAccess": {
5970259699
"value": "Enabled"
5970359700
},
@@ -59712,7 +59709,7 @@
5971259709
"_generator": {
5971359710
"name": "bicep",
5971459711
"version": "0.44.1.10279",
59715-
"templateHash": "9621160936099183182"
59712+
"templateHash": "9504607717010385151"
5971659713
}
5971759714
},
5971859715
"definitions": {
@@ -60250,6 +60247,40 @@
6025060247
}
6025160248
},
6025260249
"resources": {
60250+
"site": {
60251+
"existing": true,
60252+
"type": "Microsoft.Web/sites",
60253+
"apiVersion": "2025-03-01",
60254+
"name": "[parameters('name')]"
60255+
},
60256+
"logsConfig": {
60257+
"type": "Microsoft.Web/sites/config",
60258+
"apiVersion": "2025-03-01",
60259+
"name": "[format('{0}/{1}', parameters('name'), 'logs')]",
60260+
"properties": {
60261+
"applicationLogs": {
60262+
"fileSystem": {
60263+
"level": "Verbose"
60264+
}
60265+
},
60266+
"detailedErrorMessages": {
60267+
"enabled": true
60268+
},
60269+
"failedRequestsTracing": {
60270+
"enabled": true
60271+
},
60272+
"httpLogs": {
60273+
"fileSystem": {
60274+
"enabled": true,
60275+
"retentionInDays": 1,
60276+
"retentionInMb": 35
60277+
}
60278+
}
60279+
},
60280+
"dependsOn": [
60281+
"appService"
60282+
]
60283+
},
6025360284
"appService": {
6025460285
"type": "Microsoft.Resources/deployments",
6025560286
"apiVersion": "2025-04-01",
@@ -60293,6 +60324,7 @@
6029360324
"healthCheckPath": "[if(not(empty(parameters('healthCheckPath'))), parameters('healthCheckPath'), null())]",
6029460325
"webSocketsEnabled": "[parameters('webSocketsEnabled')]",
6029560326
"appCommandLine": "[parameters('appCommandLine')]",
60327+
"vnetRouteAllEnabled": "[parameters('vnetRouteAllEnabled')]",
6029660328
"acrUseManagedIdentityCreds": "[not(empty(parameters('acrUserManagedIdentityClientId')))]",
6029760329
"acrUserManagedIdentityID": "[if(not(empty(parameters('acrUserManagedIdentityClientId'))), parameters('acrUserManagedIdentityClientId'), null())]"
6029860330
}
@@ -60306,35 +60338,6 @@
6030660338
"name": "appsettings",
6030760339
"properties": "[parameters('appSettings')]",
6030860340
"applicationInsightResourceId": "[if(not(empty(parameters('applicationInsightResourceId'))), parameters('applicationInsightResourceId'), null())]"
60309-
},
60310-
{
60311-
"name": "logs",
60312-
"properties": {
60313-
"applicationLogs": {
60314-
"fileSystem": {
60315-
"level": "Verbose"
60316-
}
60317-
},
60318-
"detailedErrorMessages": {
60319-
"enabled": true
60320-
},
60321-
"failedRequestsTracing": {
60322-
"enabled": true
60323-
},
60324-
"httpLogs": {
60325-
"fileSystem": {
60326-
"enabled": true,
60327-
"retentionInDays": 1,
60328-
"retentionInMb": 35
60329-
}
60330-
}
60331-
}
60332-
},
60333-
{
60334-
"name": "web",
60335-
"properties": {
60336-
"vnetRouteAllEnabled": "[parameters('vnetRouteAllEnabled')]"
60337-
}
6033860341
}
6033960342
]
6034060343
},

infra/bicep/main.bicep

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ var frontendAppUrl = 'https://${frontendAppName}.azurewebsites.net'
243243
var appServicePlanName = 'asp-${solutionSuffix}'
244244
var backendContainerAppName = 'ca-${solutionSuffix}'
245245
var mcpContainerAppName = 'ca-mcp-${solutionSuffix}'
246+
var backendUsesBootstrapImage = toLower(backendContainerRegistryHostname) == 'mcr.microsoft.com' && toLower(backendContainerImageName) == 'azuredocs/containerapps-helloworld'
247+
var mcpUsesBootstrapImage = toLower(MCPContainerRegistryHostname) == 'mcr.microsoft.com' && toLower(MCPContainerImageName) == 'azuredocs/containerapps-helloworld'
246248
var storageAccountName = take('st${toLower(replace(solutionSuffix, '-', ''))}', 24)
247249
var aiSearchServiceName = 'srch-${solutionSuffix}'
248250

@@ -495,7 +497,7 @@ module backend_container_app './modules/compute/container-app.bicep' = {
495497
tags: isCustom ? union(allTags, { 'azd-service-name': 'backend' }) : allTags
496498
environmentResourceId: container_app_environment.outputs.resourceId
497499
ingressExternal: true
498-
ingressTargetPort: 8000
500+
ingressTargetPort: backendUsesBootstrapImage ? 80 : 8000
499501
managedIdentities: {
500502
userAssignedResourceIds: [userAssignedIdentity.outputs.resourceId]
501503
}
@@ -516,12 +518,14 @@ module backend_container_app './modules/compute/container-app.bicep' = {
516518
minReplicas: 1
517519
maxReplicas: 1
518520
}
519-
registries: [
520-
{
521-
server: acrLoginServer
522-
identity: userAssignedIdentity.outputs.resourceId
523-
}
524-
]
521+
registries: backendUsesBootstrapImage
522+
? null
523+
: [
524+
{
525+
server: acrLoginServer
526+
identity: userAssignedIdentity.outputs.resourceId
527+
}
528+
]
525529
containers: [
526530
{
527531
name: 'backend'
@@ -669,7 +673,7 @@ module mcp_container_app './modules/compute/container-app.bicep' = {
669673
tags: isCustom ? union(allTags, { 'azd-service-name': 'mcp' }) : allTags
670674
environmentResourceId: container_app_environment.outputs.resourceId
671675
ingressExternal: true
672-
ingressTargetPort: 9000
676+
ingressTargetPort: mcpUsesBootstrapImage ? 80 : 9000
673677
managedIdentities: {
674678
userAssignedResourceIds: [userAssignedIdentity.outputs.resourceId]
675679
}
@@ -683,12 +687,14 @@ module mcp_container_app './modules/compute/container-app.bicep' = {
683687
minReplicas: 1
684688
maxReplicas: 1
685689
}
686-
registries: [
687-
{
688-
server: acrLoginServer
689-
identity: userAssignedIdentity.outputs.resourceId
690-
}
691-
]
690+
registries: mcpUsesBootstrapImage
691+
? null
692+
: [
693+
{
694+
server: acrLoginServer
695+
identity: userAssignedIdentity.outputs.resourceId
696+
}
697+
]
692698
containers: [
693699
{
694700
name: 'mcp'

0 commit comments

Comments
 (0)