How do you resolve permission issues when deploying an Azure App Service using Azure DevOps?

We have a pretty basic NodeJS Express application that we package in a docker container and publish to an Azure Container Registry using an Azure DevOps build pipeline. This part works fine, but when we run a task to make our App Service use this newly published image we get permission issues.

We are using the following command to activate the image in our App Service in our build pipeline:

            inputs:
              azureSubscription: ${{ variables.service_connection }}
              appName: ${{ variables.app_name }}
              imageName: ${{ variables.container_registry }}/${{ variables.image_name }}:${{ parameters.stack }}

Our build pipeline is also running successfully. But when looking into my App Service it says that my application is unhealthy. When reading the logs it says:

2024-07-17T13:13:53.610Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for mycontainerrepository.azurecr.io/myimagename:my_tag not found: manifest unknown: manifest tagged by "my_tag" is not found"}
2024-07-17T13:13:53.784Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Head "https://mycontainerrepository.azurecr.io/v2/myimagename/manifests/my_tag": unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information."}
2024-07-17T13:13:53.788Z WARN  - Image pull failed. Defaulting to local copy if present.
2024-07-17T13:13:53.792Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)/home/LogFiles/2024_07_17_lw1sdlwk00013M_msi_docker.log  (https://myimagename.scm.azurewebsites.net/api/vfs/LogFiles/2024_07_17_lw1sdlwk00013M_msi_docker.log) 

When looking the documentation from Microsoft we have found this:

The task uses the service principal in the service connection to authenticate with Azure. If the service principal has expired or doesn’t have permissions to the App Service, the task fails with this error. Verify the validity of the service principal used and that it’s present in the app registration. For more information, see Use role-based access control to manage access to your Azure subscription resources. This blog post also contains more information about using service principal authentication.

in this page: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-function-app-container-v1?view=azure-pipelines

It seems to hint that the Service Principle that is used by the Service Connection that our build pipeline is using must have the correct permissions. I have verified that it does have the AcrPull permission on the Azure Container Registry though (which seems to be what the logs are complaining about), it also has the Website Contributor role on the App Service we’re deploying to.

My only way to repair this has been to go into Deployment Center and click “Disconnect” on the Azure Pipeline, and then manually configure that it should use the Azure Container Registry directly as source (the App Service has a managed Identity that has been given the AcrPull permission).

Can someone explain what the suggested way is to allow our Azure DevOps pipeline to deploy the new docker image to our App Service?

UPDATE
After some trial and error it seems the error is happening based on if we have configured Inbound IP restrictions or not. There are no outbound restrictions, but we have configured that only the health probe and some of our internal IPs should be able to access this service. If this restriction is disabled, then the image can suddenly be downloaded and things seems to work. Adding the restrictions again then keeps the service working up until the next time the Azure DevOps Pipeline does a deploy.

5

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật