Skip to content

Commit

Permalink
Fix race condition in bicep / ARM template (#564)
Browse files Browse the repository at this point in the history
### Motivation and Context
Without this change, virtually all deployments will fail when deploying
some of the extensions (MSDeploy or App Insights) for our services.

### Description
- Make each service has its own virtualNetworkConnections resource
- Add dependsOn clause for the service extensions on their respective
virtualNetworkConnections resource
- Remove some crud that had accumulated in the template files

- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
  • Loading branch information
glahaye authored Nov 2, 2023
1 parent eb9450c commit 9fedbd4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 122 deletions.
22 changes: 11 additions & 11 deletions scripts/deploy/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ resource appServiceWebDeploy 'Microsoft.Web/sites/extensions@2022-09-01' = if (d
}
dependsOn: [
appServiceWebConfig
webSubnetConnection
]
}

Expand Down Expand Up @@ -463,7 +464,6 @@ resource appServiceMemoryPipelineConfig 'Microsoft.Web/sites/config@2022-09-01'
minTlsVersion: '1.2'
netFrameworkVersion: 'v6.0'
use32BitWorkerProcess: false
vnetName: webSubnetConnection.name
vnetRouteAllEnabled: true
appSettings: [
{
Expand Down Expand Up @@ -623,6 +623,7 @@ resource appServiceMemoryPipelineDeploy 'Microsoft.Web/sites/extensions@2022-09-
}
dependsOn: [
appServiceMemoryPipelineConfig
memSubnetConnection
]
}

Expand Down Expand Up @@ -883,16 +884,6 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-05-01' = {
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
{
name: 'postgresSubnet'
properties: {
addressPrefix: '10.0.3.0/24'
serviceEndpoints: []
delegations: []
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
]
}
}
Expand Down Expand Up @@ -936,6 +927,15 @@ resource webSubnetConnection 'Microsoft.Web/sites/virtualNetworkConnections@2022
}
}

resource memSubnetConnection 'Microsoft.Web/sites/virtualNetworkConnections@2022-09-01' = {
parent: appServiceMemoryPipeline
name: 'memSubnetConnection'
properties: {
vnetResourceId: virtualNetwork.properties.subnets[0].id
isSwift: true
}
}

resource qdrantSubnetConnection 'Microsoft.Web/sites/virtualNetworkConnections@2022-09-01' = if (memoryStore == 'Qdrant') {
parent: appServiceQdrant
name: 'qdrantSubnetConnection'
Expand Down
37 changes: 20 additions & 17 deletions scripts/deploy/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.22.6.54827",
"templateHash": "7392657133670008096"
"templateHash": "9623885437439794816"
}
},
"parameters": {
Expand Down Expand Up @@ -335,7 +335,8 @@
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', format('app-{0}-webapi', variables('uniqueName')))]",
"[resourceId('Microsoft.Web/sites/config', format('app-{0}-webapi', variables('uniqueName')), 'web')]"
"[resourceId('Microsoft.Web/sites/config', format('app-{0}-webapi', variables('uniqueName')), 'web')]",
"[resourceId('Microsoft.Web/sites/virtualNetworkConnections', format('app-{0}-webapi', variables('uniqueName')), 'webSubnetConnection')]"
]
},
{
Expand Down Expand Up @@ -369,7 +370,6 @@
"minTlsVersion": "1.2",
"netFrameworkVersion": "v6.0",
"use32BitWorkerProcess": false,
"vnetName": "webSubnetConnection",
"vnetRouteAllEnabled": true,
"appSettings": [
{
Expand Down Expand Up @@ -525,8 +525,7 @@
"[resourceId('Microsoft.Search/searchServices', format('acs-{0}', variables('uniqueName')))]",
"[resourceId('Microsoft.CognitiveServices/accounts', format('cog-ocr-{0}', variables('uniqueName')))]",
"[resourceId('Microsoft.CognitiveServices/accounts', format('ai-{0}', variables('uniqueName')))]",
"[resourceId('Microsoft.Storage/storageAccounts', format('st{0}', variables('rgIdHash')))]",
"[resourceId('Microsoft.Web/sites/virtualNetworkConnections', format('app-{0}-webapi', variables('uniqueName')), 'webSubnetConnection')]"
"[resourceId('Microsoft.Storage/storageAccounts', format('st{0}', variables('rgIdHash')))]"
]
},
{
Expand All @@ -540,7 +539,8 @@
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', format('app-{0}-memorypipeline', variables('uniqueName')))]",
"[resourceId('Microsoft.Web/sites/config', format('app-{0}-memorypipeline', variables('uniqueName')), 'web')]"
"[resourceId('Microsoft.Web/sites/config', format('app-{0}-memorypipeline', variables('uniqueName')), 'web')]",
"[resourceId('Microsoft.Web/sites/virtualNetworkConnections', format('app-{0}-memorypipeline', variables('uniqueName')), 'memSubnetConnection')]"
]
},
{
Expand Down Expand Up @@ -836,16 +836,6 @@
"privateEndpointNetworkPolicies": "Disabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
},
{
"name": "postgresSubnet",
"properties": {
"addressPrefix": "10.0.3.0/24",
"serviceEndpoints": [],
"delegations": [],
"privateEndpointNetworkPolicies": "Disabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
]
},
Expand Down Expand Up @@ -899,6 +889,19 @@
"[resourceId('Microsoft.Network/virtualNetworks', format('vnet-{0}', variables('uniqueName')))]"
]
},
{
"type": "Microsoft.Web/sites/virtualNetworkConnections",
"apiVersion": "2022-09-01",
"name": "[format('{0}/{1}', format('app-{0}-memorypipeline', variables('uniqueName')), 'memSubnetConnection')]",
"properties": {
"vnetResourceId": "[reference(resourceId('Microsoft.Network/virtualNetworks', format('vnet-{0}', variables('uniqueName'))), '2021-05-01').subnets[0].id]",
"isSwift": true
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', format('app-{0}-memorypipeline', variables('uniqueName')))]",
"[resourceId('Microsoft.Network/virtualNetworks', format('vnet-{0}', variables('uniqueName')))]"
]
},
{
"condition": "[equals(parameters('memoryStore'), 'Qdrant')]",
"type": "Microsoft.Web/sites/virtualNetworkConnections",
Expand Down Expand Up @@ -1159,4 +1162,4 @@
"value": "[concat(createArray(), if(parameters('deployWebSearcherPlugin'), createArray(format('function-{0}-websearcher-plugin', variables('uniqueName'))), createArray()))]"
}
}
}
}
94 changes: 0 additions & 94 deletions scripts/deploy/object.txt

This file was deleted.

0 comments on commit 9fedbd4

Please sign in to comment.