Reputation: 85
I am trying to deploy a image from Azure container registry to Azure function using Azure pipelines and its not working, below are my observation:
When deploying the same image to web app its working. This proves that it is not an issue of access of service connection. i:e it is able to pull the image from ACR.
The service connection has subscription level access and all the resources web app, function and acr are in the same resource group.
From the Advanced Tools-->Current Docker log output , it is giving me authentication issue. But my admin access in ACR is already enabled and the service connection is working fine for web app.
2023-07-27T00:01:26.211Z INFO - Pulling image: acrdevintegration.azurecr.io/apiintegtation:1662 2023-07-27T00:01:26.274Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get "https://acrdevintegration.azurecr.io/v2/apiintegtation/manifests/1662": unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information."}
2023-07-27T00:01:26.274Z ERROR - Pulling docker image acrdevintegration.azurecr.io/apiintegtation:1662 failed: 2023-07-27T00:01:26.321Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get "https://acrdevintegration.azurecr.io/v2/apiintegtation/manifests/1662": unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information."}
2023-07-27T00:01:26.321Z WARN - Image pull failed. Defaulting to local copy if present. 2023-07-27T00:01:26.322Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository) 2023-07-27T00:01:26.323Z INFO - Stopping site azurefunction-dev-integration because it failed during startup.
Below is my azure pipeline code, let me know where I am going wrong.
trigger:
resources:
variables:
dockerRegistryServiceConnection: 'b78ea80b-5431-432a-a2e0-01a948ab3e60'
imageRepository: 'apiintegtation'
containerRegistry: 'acrdevintegration.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.BuildId)'
vmImageName: 'ubuntu-latest'
stages:
- stage: Build
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build an image to container registry
inputs:
containerRegistry: $(dockerRegistryServiceConnection)
repository: $(imageRepository)
command: 'build'
Dockerfile: $(dockerfilePath)
arguments: '--build-arg FOLDER=weather --build-arg PORT=3000'
tags: |
$(tag)
latest
- task: Docker@2
displayName: Push an image to container registry
inputs:
containerRegistry: $(dockerRegistryServiceConnection)
repository: $(imageRepository)
command: 'push'
tags: |
$(tag)
latest
- task: AzureWebAppContainer@1
inputs:
azureSubscription: 'Integration'
appName: 'testimage123'
containers: '$(containerRegistry)/$(imageRepository):$(tag)'
- task: AzureFunctionAppContainer@1
inputs:
azureSubscription: 'Integration'
appName: 'azurefunction-dev-integration'
imageName: '$(containerRegistry)/$(imageRepository):$(tag)'
Upvotes: 0
Views: 1169
Reputation: 85
After lot of troubleshooting found the issue. The problem was in the way both the resources were created. The web app was created using the docker image from the ACR( via the Docker tab) , thus the Docker username/password and url got embedded in the configuration when it was started. Thus subsequent deployment to the web app were successful as it contained the ACR credential.
However since azure function does not provide docker tab while creation, I created it without any image. Once created I used the pipeline to deploy my image to the function. Thus the function did not had the ACR credential hence deployment was failing.
Learning:
Upvotes: 1