Skip to content

Commit

Permalink
Create dependencies to for waiting some time for the container registry
Browse files Browse the repository at this point in the history
  • Loading branch information
vhvb1989 committed Jul 17, 2024
1 parent fad80a9 commit 4d579d4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions infra/core/host/container-apps.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ param daprEnabled bool = false

module containerAppsEnvironment 'container-apps-environment.bicep' = {
name: '${name}-container-apps-environment'
// Container Envieronment does depend directly on the registry, but we want to wait for the registry to be ready
// The time for creating the container environment is used to wait for the container registry to be ready (DNS propagation)
dependsOn: [containerRegistry]
params: {
name: containerAppsEnvironmentName
location: location
Expand All @@ -34,6 +37,28 @@ module containerRegistry 'container-registry.bicep' = {
}
}

// Wait for the registry to be ready before continuing
// DNS propagation can take up to 60 sec
// see: https://learn.microsoft.com/en-us/azure/dns/dns-faq#how-long-does-it-take-for-dns-changes-to-take-effect-
resource waitForRegistry 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
name: 'wait-for-registry-app-container-registry'
location: location
kind: 'AzureCLI'
dependsOn: [
containerAppsEnvironment
]
properties: {
azCliVersion: '2.61.0'
retentionInterval: 'PT1H' // Retain the script resource for 1 hour after it ends running
timeout: 'PT5M' // Five minutes
cleanupPreference: 'OnSuccess'
scriptContent: '''
# setting up deployment script takes about 1 minute, which is the max time we need to wait for DNS propagation
echo "Waited at least 60 seconds for DNS propagation. If container registry is not found, an error will be returned."
'''
}
}

output defaultDomain string = containerAppsEnvironment.outputs.defaultDomain
output environmentName string = containerAppsEnvironment.outputs.name
output environmentId string = containerAppsEnvironment.outputs.id
Expand Down

0 comments on commit 4d579d4

Please sign in to comment.