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 provide ImageToDeploy and AcrName for docker token authentication. #11

Closed duncan-G closed 1 year ago

duncan-G commented 1 year ago

It is no longer possible to provide ImageToDeploy and AcrName arguments for a pre built image that requires authentication to access. According to the documentation, if ImageToDeploy requires authentication, then ArcName can be provided to authenticate to the registry using token authentication (if AcrUserName and AcrPassword are not provided). This is also in the code:

CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name $(acrName)--output json --expose-token --only-show-errors | jq -r '.accessToken');
 docker login acrName.azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1'.

With the new changes made, both appSourcePath and acrName are now required together. When these 2 are provided, the tasks attempts to builds the image from source and deploys to the registry.

This does not seem like an intended change. It should be that if appSourcePath is provided, then acrName is required, but if acrName is provided, appSourcePath is not required.

roybilton commented 1 year ago

Hi my existing code also breaks, this was working yesterday perfectly when an existing image is pull fronm the ACR and add it to the ACA

derSchtefan commented 1 year ago

Reported wrongly at; https://github.com/microsoft/azure-pipelines-tasks/issues/17687

We have the issue that we do not even specify acrName, only imageToDeploy, and still get that error message.

Guillaume-R-FLOSS commented 1 year ago

As a work around we could at least target the previous version of this task like this : AzureContainerAppsRC@0.1.7

duncan-G commented 1 year ago

As a work around we could at least target the previous version of this task like this : AzureContainerAppsRC@0.1.7

@Guillaume-R-FLOSS Did you have to do anything else to get this to work. I get the exception 'Invalid step task reference AzureContainerAppsRC@0.1.7'

heitor-marcos commented 1 year ago

I'm facing the same problem. I want to set only the Azure Container Registry Name value in my release pipeline, since my image has already been built and pushed to the container registry by the build pipeline that i have. With version 0.1.7 this was possible, but now i'm getting the error: the arguments appSourcePath and acrName must either be provided together or not at all. if i try to delete the "Azure Container Registry Name" and leave it blank the error changes because some values become undefined in this commad: [command]/usr/bin/bash -c CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name undefined --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login undefined.azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1

As can be seen --name undefined and docker login undefined.azurecr.io in version 0.1.7 with only acrName filled in it would generate correctly replacing the "undefined" with the filled in value in acrName.

cormacpayne commented 1 year ago

Hey folks, apologies for this issue -- there was a misunderstanding with the argument validation when it came to when acrName should be provided along with appSourcePath. I just merged a PR that fixes this so that acrName is only required when appSourcePath is provided, not the other way around, so acrName can now be used with the imageToDeploy argument as outlined in this issue.

The 0.1.9 version of the AzureContainerAppsRC task has been released with this fix -- please let me know if this issue still persists or if there are any other issues you're facing with the latest set of releases.

heitor-marcos commented 1 year ago

I was about to send you a Pull Request where i extracted the acrName from the imageToDeploy using the regex /(.*?)\..*/ But 0.1.9 fixed the issue. Thanks!!!

Guillaume-R-FLOSS commented 1 year ago

As a work around we could at least target the previous version of this task like this : AzureContainerAppsRC@0.1.7

@Guillaume-R-FLOSS Did you have to do anything else to get this to work. I get the exception 'Invalid step task reference AzureContainerAppsRC@0.1.7'

@duncan-G Nope we didn't had to do extra thing to target this specific version. As a side note we use Azure Hosted Agent with ubuntu-latest image.