AzureContainerApps@1任务失败,无法针对ACR示例进行身份验证

ubof19bj  于 2023-06-30  发布在  其他
关注(0)|答案(1)|浏览(67)

我正在尝试通过Azure DevOps管道使用VMSS代理从上一步中构建的ACR中的dockerimage更新containerApp。变量acrContainerRegistry包含值myregistry.azurecr.io

- stage: Build
// defined jobs 
    - task: Docker@2
          displayName: Build and push an image to container registry
          inputs:
            command: buildAndPush
            repository: $(acrImageRepository)
            dockerfile: $(dockerfilePath)
            containerRegistry: $(dockerRegistryConn)
            tags: |
              $(tag)
- stage: DeployContainerApp
//defined jobs
       - task: AzureContainerApps@1
         inputs:
           azureSubscription: $(armConn)
           acrName: $(acrContainerRegistry)
           containerAppName: $(CONTAINER_APP_NAME)
           resourceGroup: $(RG_NAME)
           imageToDeploy: $(acrContainerRegistry)/$(acrImageRepository)-$(Build.SourceBranchName):latest
        containerAppEnvironment: $(CONTAINER_APP_ENV_NAME)
        location: $(CONTAINER_APP_ENV_LOCATION_NAME)
        ingress: "external"
        targetPort: 80

docker任务成功,镜像推送到acr,AzureContainerApps@1任务失败,出现此错误

/usr/bin/bash -c CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name myregistry.azurecr.io --output json --expose-token --only-show-errors | jq -r '.accessToken'); 
docker login myregistry.azurecr.io.azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1
    ##[error]Unable to run provided bash command 'CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name myregistry.azurecr.io --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login myregistry.azurecr.io.azurecr.io -u 000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1'.
    ##[error]Unable to authenticate against ACR instance 'myregistry.azurecr.io.azurecr.io' with access token.
    ##[error]The process '/usr/bin/bash' failed with exit code 1

这里我注意到docker正在尝试使用一个额外的azurecr.io登录

myregistry.azurecr.io.azurecr.io。这是否失败的原因?我不知道这是怎么加上去的。

有人能帮忙吗?

ca1c2owp

ca1c2owp1#

myregistry.azurecr.io.azurecr.io。这是否失败的原因?

yes @coder.将extra . www.example.com添加azurecr.io到容器注册表URL导致问题。
我尝试在我的环境中执行您的代码来识别问题,我遇到了与您相同的error
为了解决这个问题,我修改了Azure容器应用程序任务,为acrName参数提供了一个不同的名称,如您提供的屏幕截图所示。

下面是我执行的更新后的代码,我收到了预期的结果:

trigger: none

pool:
  vmImage: ubuntu-latest

steps:
- task: Docker@2
  displayName: Build and push an image to container registry
  inputs:
    containerRegistry: '$(dockerRegistryConn)'
    repository: '$(acrImageRepository)'
    command: 'buildAndPush'
    Dockerfile: 'Dockerfile'
    tags: |
      $(Build.BuildId)
      latest

- task: AzureContainerApps@1
  inputs:
    azureSubscription: $(armConn)
    acrName: $(acrContainerName)        # provide conatiner registry name here. In my case it is 'acrvjy'
    containerAppName: $(CONTAINER_APP_NAME)
    resourceGroup: $(RG_NAME)
    imageToDeploy: $(acrContainerRegistry)/$(acrImageRepository):latest #provide the full name of the repository. In my case it is  acrvjy.azurecr.io/pyimg:latests
    containerAppEnvironment: $(CONTAINER_APP_ENV_NAME)
    location: $(CONTAINER_APP_ENV_LOCATION_NAME)
    ingress: "external"
    targetPort: 80

输出:https://i.imgur.com/V2LcTX3.png

相关问题