Open
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the pre-deploy hook to make ACR cloud builds more reliable by explicitly providing a resource group to az acr build, helping avoid registry resolution/deployment issues during container deployment.
Changes:
- Add
--resource-group $env:AZURE_RESOURCE_GROUP_NAMEto theaz acr buildinvocation indeployment/hooks/predeploy.ps1.
| if ($backendClientId) { $acrBuildArgs += @("--build-arg", "ENTRA_BACKEND_CLIENT_ID=$backendClientId") } | ||
| if ($appInsightsConnStrEscaped) { $acrBuildArgs += @("--build-arg", "APPLICATIONINSIGHTS_FRONTEND_CONNECTION_STRING=$appInsightsConnStrEscaped") } | ||
| $buildOutput = az acr build --registry $acrName --image "web:$imageTag" ` | ||
| $buildOutput = az acr build --registry $acrName --resource-group $env:AZURE_RESOURCE_GROUP_NAME --image "web:$imageTag" ` |
There was a problem hiding this comment.
az acr build is now using $env:AZURE_RESOURCE_GROUP_NAME directly, but this script already resolves the resource group via Get-AzdValue into $resourceGroup (with a fallback when env vars aren’t present). Using the env var here can make ACR cloud builds fail when the hook is run without injected env vars even though azd env get-value works. Use $resourceGroup (and fail fast if it’s empty) for consistency with the rest of the script.
Suggested change
| $buildOutput = az acr build --registry $acrName --resource-group $env:AZURE_RESOURCE_GROUP_NAME --image "web:$imageTag" ` | |
| if ([string]::IsNullOrWhiteSpace($resourceGroup)) { throw "AZURE_RESOURCE_GROUP_NAME is required for ACR cloud build" } | |
| $buildOutput = az acr build --registry $acrName --resource-group $resourceGroup --image "web:$imageTag" ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
I suggest to avoid ACR deployment issue during container deployment, need to chagne predeploy.ps1 like as below,
$buildOutput = az acr build --registry $acrName --image "web:$imageTag" ` $buildOutput = az acr build --registry $acrName --resource-group $env:AZURE_RESOURCE_GROUP_NAME --image "web:$imageTag" `