共用方式為


無法使用受控識別驗證從 Azure Container Registry 提取映像

本文討論如何使用受控識別,針對從 Azure Container Registry 部署至 Azure 容器執行個體 (ACI) 的映像提取失敗進行疑難解答。

徵兆

當您嘗試使用受控識別從私人端點後方執行的 Azure 容器登錄部署容器群組和提取映射時,映射提取會失敗。

原因

以下是映像提取失敗的一些原因:

  • 從 ACI 端:

    • 根據部署容器群組時所使用的 ACI API 版本,容器群組 ARM 範本提供的認證格式可能無效。
    • 在容器群組中使用受控識別可能會違反 ACI 限制。
    • ARM 樣本中的容器群組定義可能格式不正確。
  • 從 ACR 端:

    • 您可能使用舊版 API。
    • 您可能使用容器登錄的私人 DNS 區域。

從 ACI 端進行疑難解答

  1. 檢查您是否使用早於 2021-07-01 的 ACI API 版本。

    若是如此,您可能會看到「InvalidImageRegistryCredentialType」錯誤:

    $ az deployment group create -g <resourcegroupname> --template-file containergroup_trusted.json 
    Deployment failed. Correlation ID: <Correlation ID>. { 
      "error": { 
        "code": "InvalidImageRegistryCredentialType", 
        "message": "Identity in 'imageRegistryCredentials' of container group 'acrtestcontainergroup' is not supported." 
      } 
    } 
    

    若要解決此問題,請使用 ACI API 2021-07-01 版或更新版本。

  2. 檢查您是否違反任何 ACI 限制。

    限制包括:

    • 虛擬網路插入的容器群組。
    • Windows Server 2016 容器群組。
    • 嘗試解析 ACR 的私人 DNS 區域。

    若要解決此問題,請確定您不會違反這些限制。

  3. 檢查容器群組定義是否正確形成。

    如果沒有,您可能會看到下列錯誤:

    • 錯誤碼 “AmbiguousImageResitryCredentialType”:

      Deployment failed. Correlation ID: <Correlation ID>. { 
      "error": { 
          "code": "AmbiguousImageResitryCredentialType", 
          "message": "The registry credential type in the 'imageRegistryCredentials' of container group 'acrtestcontainergroup' cannot be detected. Please set exactly one of username or identity" 
      } 
      } 
      
    • 錯誤碼 「InvalidImageRegistryIdentity」:

      Deployment failed. Correlation ID: <Correlation ID>. { 
      "error": { 
          "code": "InvalidImageRegistryIdentity", 
          "message": "The identity in the 'imageRegistryCredentials' of container group 'acrtestcontainergroup' not found in container group identity list." 
      } 
      } 
      
    • 錯誤碼 “InvalidRequestContent”:

      Deployment failed. Correlation ID: <Correlation ID>. { 
      "error": { 
          "code": "InvalidRequestContent", 
          "message": "The request content was invalid and could not be deserialized: 'Required property 'server' not found in JSON. Path 'properties.imageRegistryCredentials[0]', line 1, position 586.'." 
      } 
      }
      

    若要解決此問題,您必須在 ARM 範本中提供下列屬性:

    • server ImageRegistryCredentialidentity 屬性。
    • type ContainerGroupIdentityuserAssignedIdentity 屬性。

從 ACR 端進行疑難解答

  1. 檢查受控識別 AcrPull 是否已指派角色。

    如果沒有,您可能會看到「無法存取的Image」錯誤:

    Deployment failed. Correlation ID: <Correlation ID>. { 
      "error": { 
        "code": "InaccessibleImage", 
        "message": "The image 'myacr.azurecr.io/pythonworker:v1' in container group 'acrtestcontainergroup' is not accessible. Please check the image and registry credential." 
      } 
    } 
    

    若要解決此問題,請將角色授 AcrPull 與受控識別。 如需詳細資訊,請參閱 授與身分識別許可權以存取其他 Azure 資源

  2. 檢查 ACR 是否已啟用受信任的服務 。 如果沒有,請啟用受信任的服務。

與我們連絡,以取得說明

如果您有問題或需要相關協助,請建立支援要求,或詢問 Azure community 支援。 您也可以向 Azure 意見反應社群提交產品意見反應。