0
votes

I have a weird issue, possible I am missing something. The web app is created as a container with default settings(Quickstart) and I am using Azure Container Registry to push my docker image. I have pipeline which logins to the ACR, build and pushes image, and then deploys the image to the web app. All these tasks are successful. But when I got to the webapp in azure portal, the image source is set to docker hub and not the Azure Container registry.The full inage name and tag are of the ACR. Any suggestion what I am missing?enter image description here

Update: I have added the pipeline.yml file for reference, if it helps. I am logging in to registry while pushing docker image, I confirm that the image is push in the ACR.

          - task: Docker@2
            displayName: Login to QA Azure Container Registry
            inputs:
              command: login
              containerRegistry: $(azureSubscriptionContainer) #Docker Registry type Service connection
          - task: Docker@2
            displayName: Build and Push
            inputs:
              command: buildAndPush
              repository: $(repository) #custom name of repository in ACR
              tags: $(Build.BuildId)
          - task: AzureRMWebAppDeployment@4
            displayName: Azure App Service Deploy
            inputs:
              appType: webAppContainer
              ConnectedServiceName: $(azureSubscription)    #ARM service connection
              WebAppName: $(webApp)
              DockerNamespace: $(dockerNameSpace) #ACR namespace myacr.azurecr.io
              DockerRepository: $(repository) #custom name of repository in ACR
              DockerImageTag: $(Build.BuildId)
2
I see that you have selected Docker Hub - try select Azure Conteiner RegistryBartosz Pelikan
Yes, is it mandatory to do it manually? I am deploying it through pipeline and selecting Azure Container Registry access won't be available with dev team.Shubham
These images is private?Bartosz Pelikan
@BartoszPelikan Yes, they are private imagesShubham

2 Answers

1
votes

Create App Service with CLI:

az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app-name> --deployment-container-image-name <azure-container-registry-name>.azurecr.io/mydockerimage:v1.0.0

This is for public images, but according the documentation if you want to use private image you must also configure registry credentials to yours Web App and if this is not Docker registry you must provide -docker-registry-server-url:

az webapp config container set --name <app-name> --resource-group myResourceGroup --docker-custom-image-name <azure-container-registry-name>.azurecr.io/mydockerimage:v1.0.0 --docker-registry-server-url https://<azure-container-registry-name>.azurecr.io --docker-registry-server-user <registry-username> --docker-registry-server-password <password>
2
votes

TLDR: You need to either select the repository in the UI; or add the credentials via ARM or AzureCLI.

https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/webapp-on-container-linux?view=azure-devops&tabs=dotnet-core%2Cyaml#configure-registry-credentials-in-web-app

You can use your deployment task like you are doing right now, not all developers need access to the WebApp. However, you need to set up the credentials to the registry at least once. The UI will basically show its "best guess" for how to intepret the underlying configuration.

https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image#configure-registry-credentials-in-web-app

You could also do that with every pipeline run, tough I would not recommend that.

Sidenote: You can also have your webapp automatically pull a certain tag whenever it is updated in the container registry if you select "Continuous deployment".