Azure / container-apps-deploy-pipelines-task

Azure Pipelines Task (Release Candidate) for building and deploying Azure Container Apps
MIT License
6 stars 10 forks source link

Unable to update Azure Container App via 'az containerapp update' command #28

Closed dyardy closed 1 year ago

dyardy commented 1 year ago

I have a .net (api) solution comprised of a few projects setup as a container app. I can build and run locally all fine.

I am using AzureContainerAppsRC@1 with the following yaml

steps:
- task: AzureContainerAppsRC@1
  displayName: Build and deploy Container App XXXXXXProcessor
  inputs:
    connectedServiceNameARM: 'XXXXXX_AzureResourceManager_Staging'
    runtimeStack: mcr.microsoft.com/oryx/dotnetcore:6.0
    appSourcePath: '$(Build.SourcesDirectory)'    
    acrName: 'xxxxxxappstagingcontainerregistry'    
    containerAppName: 'xxxxxxprocessor-staging'
    resourceGroup: 'rg-WUS-XXXXXX-General-Staging'

When running this pipeline, it builds all fine however it appears that there is issue updating the container app xxxxxxprocessor-staging when the pipeline log shows the failure

ERROR: (WebhookInvalidParameterValue) The following field(s) are either invalid or missing. Invalid value: "xxxxxxappstagingcontainerregistry.azurecr.io/ado-task/container-app:31422.20230412.11": GET https:?scope=repository%3Aado-task%2Fcontainer-app%3Apull&service=xxxxxxappstagingcontainerregistry.azurecr.io: **UNAUTHORIZED: authentication required,** 
visit https://aka.ms/acr/authorization for more information.: template.containers.simple-hello-world-container.image.
##[error]Error Code: [1]
##[error]Error: Unable to update Azure Container App via 'az containerapp update' command.

I have setup XXXXXX_AzureResourceManager_Staging (to be a contributor in this resource group) but still seeing this issue.

What context is this running in? (I assumed it was XXXXXX_AzureResourceManager_Staging which is the azure resource manager)

When I created the container app, i selected the sample hello world app "simple-hello-world-container".

The pipeline above would put in another container app (is there some name conflict) as I am pushing in new app into the container?

dyardy commented 1 year ago

Resolution: Navigate to your ACR resource (container registry), select Access keys, copy Username and password and within your pipeline add fields acrUsername and acrPassword and re-run

cormacpayne commented 1 year ago

@dyardy Hey there, apologies that you were running into this issue -- providing values for the acrUsername and acrPassword arguments will give the Task a direct way to authenticate calls to your ACR instance and should allow for pushing up the image that was built. Without those arguments, an access token should be generated from the credentials provided with connectedServiceNameARM, so it may have been the case that the account/service principal associated with that service connection may not have had proper permissions to push and/or pull images from the provided ACR instance.

It appears that this is now working for you after providing the credentials as arguments, but please feel free to reach out if you have any other issues!

CodeCraftPavan commented 1 year ago

hello @cormacpayne I have tried to pass the values of acrUsername and acrPassword while configuring a release pipeline, And i am still getting this error while I add agent job "Azure Container Apps Deploy". FYI: Trying to host .NET Core app using Azure Container App service

Tofan-Jena commented 8 months ago

Hi @cormacpayne , providing values for the acrUsername and acrPassword is not secure, and many organizations would not go with enabling the adminuser for acr.

how can we update the existing image to the container app, since the above step is failing.