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

Error when creating the container app #33

Open franperezlopez opened 1 year ago

franperezlopez commented 1 year ago

Hi,

I've got an error when using the task and if the application container is not already created. These are the inputs for the task:

  - task: AzureContainerApps@1
    inputs:
      azureSubscription: ${{ parameters.service_connection }}
      acrName: $(acr_name)
      appSourcePath: '$(System.DefaultWorkingDirectory)'
      dockerfilePath: docker/conf/Dockerfile
      imageToBuild: '$(acr_name).azurecr.io/$(conf):$(build.buildid)'
      containerAppName: $(conf)
      resourceGroup: $(resource_group)
      containerAppEnvironment: $(container_app_environment)
      location: $(location)
      ingress: external
      environmentVariables: 'OPENAI_API_BASE=$(OPENAI_API_BASE)'

The error comes when the task tries to execute the following command:

[command]/usr/bin/az containerapp create -n conf -g rg-i xxx.azurecr.io/conf:222173 --environment conf_environment --target-port 8080   
ERROR: (InvalidParameterValueInContainerTemplate) The following field(s) are either invalid or missing. Field 'template.containers.conf.image' is invalid with details: 'Invalid value: "xxx.azurecr.io/conf:222173": GET https:?scope=repository%3Aconf%3Apull&service=xxx.azurecr.io: UNAUTHORIZED: authentication required, visit https://aka.ms/acr/authorization for more information.';.
##[error]Error Code: [1]
##[error]Error: Unable to create Azure Container App via 'az containerapp create' command.

I tested the command on my dev machine, and I got the same result. But I've got it working when adding the parameter --registry-server to the command:

az containerapp create -n conf -g rg -i xxx.azurecr.io/conf:222173 --environment conf_environment --ingress external --target-port 8080 --env-vars OPENAI_API_BASE=https://api.com/ --registry-server xxx.azurecr.io
cormacpayne commented 1 year ago

@franperezlopez Hey there, thanks for filing this issue -- are you able to also provide values for the acrUsername and acrPassword arguments to this task? That should propagate these values to the az containerapp create command under-the-hood as --registry-server, --registery-username and --registry-password arguments.

franperezlopez commented 1 year ago

Hi, I tested using the username and password, but it didn't work ...

nellyk commented 1 year ago

@cormacpayne hello, i'm facing the same issue and i added a username and password

/usr/bin/az containerapp create -n ado-task-app-166-20230725-18 -g xxxxxxxxresourcegroup -i xxxxxx.azurecr.io/ado-task/container-app:166.20230725.18 --environment ado-task-app-157-20230725-9-env
 --registry-server xxxxx.azurecr.io --registry-username xxxxxx --registry-password xxxxxx --ingress external --target-port 8080
ERROR: Bad Request(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""[http://www.w3.org/TR/html4/strict.dtd">](http://www.w3.org/TR/html4/strict.dtd%22%3E)
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid URL</h2>
<hr><p>HTTP Error 400. The request URL is invalid.</p>
</BODY></HTML>
)

let me know if you'd like to troubleshoot with me, i suspect this is a line issue and the commands splits into two steps. This causes the second part of the above script from --registry part fail

Running the above command on cli deploys the container app successfully

GK-winamp commented 5 months ago

@nellyk Were you able to resolve this? I'm stuck with the same issue.

nellyk commented 5 months ago

@GK-winamp i eventually used bicep and AzureResourceManagerTemplateDeployment task to deploy the container app.

@cormacpayne did you get a chance to look into this?

cormacpayne commented 5 months ago

@nellyk Hey folks, unfortunately I'm no longer working on this specific project -- @harryli0108 do you happen to know who the contact for these items should be moving forward?

harryli0108 commented 5 months ago

Hi @nellyk sorry for the delayed reply on this issue. I'll take a look on this one and see if I can reproduce the same thing on my setup.

The 400 BadRequest should be resolved by the latest commit. Could you confirm that you're running on the AzureContainerAppsRC@1 with latest version? The AzureContainerApps@1 may not contain the fix, as the fix of the PR hasn't been merged yet. But we did release the fix in our release candidate task.

GK-winamp commented 5 months ago

Confirming, that the issue is fixed in RC@1 - all good. Thanks!

harryli0108 commented 5 months ago

@GK-winamp Thanks for confirming! Please feel free to open new issues and tag me if you run into other issues with the RC task. Meanwhile, I'll keep the people in the thread updated once the main task is updated.