azure-dev: [Aspire] azd up sometimes fails because of not reaching ACR

When creating new Azure resources and publishing the app, azd up sometimes fails because it cannot access the ACR. Repeating it, everything succeeds. For a better user experience, I think it would be useful to check for the ACR to be available and repeat the check before failing the deployment.

I had this issue when deploying to East US 2 from within Europe. This time creating the Container Apps Environment was a lot faster than previous experiences. It looks like that’s why this failed.

Versions: azd version 1.6.1 (commit eba2c978b5443fdb002c95add4011d9e63c2e76f) aspire 8.0.0-preview.3.24105.21/8.0.100

Packaging services (azd package)

SUCCESS: Your application was packaged for Azure in 5 seconds.

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

Subscription: <redacted>
Location: East US 2

  You can view detailed progress in the Azure Portal:
  https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/<redacted>

  (✓) Done: Resource group: rg-codebreaker-packt12us
  (✓) Done: Log Analytics workspace: law-okccxl67xgpc6
  (✓) Done: Container Registry: acrokccxl67xgpc6
  (✓) Done: Container Apps Environment: cae-okccxl67xgpc6
  (✓) Done: Container App: redis
  (✓) Done: Azure Cosmos DB: codebreakercosmosokccxl67xgpc6

SUCCESS: Your application was provisioned in Azure in 3 minutes 16 seconds.
You can view the resources created under the resource group rg-codebreaker-packt12us in Azure Portal:
https://portal.azure.com/#@/resource/subscriptions/<redacted>

Deploying services (azd deploy)

  (x) Failed: Deploying service blazor

ERROR: failed deploying service 'blazor': failing invoking action 'deploy', logging in to registry: failed logging into container registry, token: failed getting ACR token: POST https://acrokccxl67xgpc6.azurecr.io/oauth2/exchange
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE UNAVAILABLE
--------------------------------------------------------------------------------
Response contained no body
--------------------------------------------------------------------------------
, admin: cannot find registry with name 'acrokccxl67xgpc6' and subscriptionId '<redacted'

ERROR: error executing step command 'deploy --all': failed deploying service 'blazor': failing invoking action 'deploy', logging in to registry: failed logging into container registry, token: failed getting ACR token: POST https://acrokccxl67xgpc6.azurecr.io/oauth2/exchange
--------------------------------------------------------------------------------
RESPONSE 404: 404 Not Found
ERROR CODE UNAVAILABLE
--------------------------------------------------------------------------------
Response contained no body
--------------------------------------------------------------------------------
, admin: cannot find registry with name 'acrokccxl67xgpc6' and <redacted>

After starting the deployment again, everything succeeded.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@vhvb1989 is it related to the admin user authn error we were seeing earlier?

No. This is a timing issue. By the time deploy runs, the Azure Container Registry is still not discoverable by azd (b/c it might take a few seconds for Azure to propagate the resource existents) .

We have the same issue for Azure Web Apps.

azd makes 3 retries by deafult, but I think we need to add some exponential delay time between retries to make it more reliable.

Update from ACA team:

Looking through the deployment issue maybe this helps:
We use Azure DNS Zones to generate the ACR’s DNS and according to their documentation there’s an up to 60 seconds propagation delay time. If the endpoint ain’t working just after creation but works soon after. Using a delay might fix your issues. Here’s Doc on the subject: https://techcommunity.microsoft.com/t5/azure-database-support-blog/add-wait-operation-to-arm-template-deployment/ba-p/2915342 https://learn.microsoft.com/en-us/azure/dns/dns-faq

What’s the best way to find a matching azd version for the Aspire daily builds?

We’ve been trying to sync merging features in dotnet/aspire which requires changes to azd until the azd change is ready. By doing this, we are keeping azd-daily build compatible with aspire-daily build. However, sometime dotnet/aspire is ready and azd needs some more extra time, so the change in Aspire is merged and the azd-daily becomes incompatible with aspire-daily for a few days. That’s the current case, but it is not too often.

Once Aspire GA, this should stop happening, as there should not be breaking changes on top of GA.