Azure Batch NodePreparationError 试图从 Azure 容器注册表中获取 Docker 图像
Azure Batch NodePreparationError trying to fetch Docker image from Azure Container Registry
我正在尝试 运行 Ubuntu VM 上的 Azure Batch 任务,其中包含从私有 Azure 容器注册表中提取的映像。池中的节点创建失败并出现以下错误,无论我是否预取:
Code: NodePreparationError
Message:
An error occurred during node preparation
Values:
Error - Hit unexpected error installing containers
Message - 400, message='Bad Request', url=URL('http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/&mi_res_id=/subscriptions/7bd2fd6e-1cb6-4db2-82fe-67c7ea3024cd/resourceGroups/SANDBOX/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my_uami')
基准:我有一个包含资源组的 Azure 订阅。在资源组中是
- 容器注册表,
- 一个批处理帐户,并且
- 用户分配的托管标识。
UAMI 在 Container Registry 和 Batch Account 的身份边栏中分配。管理员为我的订阅分配了 AcrPull
角色。
我可以将图像拉到我的本地机器上,所以我知道它存在。我已经尝试 运行在来自 Docker Hub 的预取 python3.7-slim
图像上执行一个简单的任务并成功了,所以问题出在 Batch 和 ACR 之间。
这是一个演示问题的最小示例:
from azure.batch import BatchServiceClient
from azure.batch.batch_auth import SharedKeyCredentials
from azure.batch.models import (
ComputeNodeIdentityReference,
ContainerConfiguration,
ContainerRegistry,
ImageReference,
JobAddParameter,
PoolAddParameter,
PoolInformation,
VirtualMachineConfiguration,
)
if __name__ == '__main__':
batch_service_client = BatchServiceClient(
SharedKeyCredentials('batchtest2021', 'GZTn…………………………………pGJ+gNE…………………………dvw=='),
batch_url='https://batchtest2021.westeurope.batch.azure.com/',
)
pool_id = 'my_test_pool'
new_pool = PoolAddParameter(
id=pool_id,
virtual_machine_configuration=VirtualMachineConfiguration(
container_configuration=ContainerConfiguration(
container_image_names=[
'myprivateacr.azurecr.io/mydockerimage:latest',
],
container_registries=[
ContainerRegistry(
registry_server='myprivateacr.azurecr.io',
identity_reference=ComputeNodeIdentityReference(
resource_id=f'/subscriptions/7bd2fd6e-1cb6-4db2-82fe-67c7ea3024cd/resourceGroups/SANDBOX/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my_uami'
),
),
],
),
image_reference=ImageReference(
publisher='microsoft-azure-batch',
offer='ubuntu-server-container',
sku='20-04-lts',
version='latest',
),
node_agent_sku_id='batch.node.ubuntu 20.04',
),
vm_size='STANDARD_A2M_V2',
target_dedicated_nodes=2,
)
batch_service_client.pool.add(new_pool)
job = JobAddParameter(id='sample_job_id', pool_info=PoolInformation(pool_id=pool_id))
batch_service_client.job.add(job)
代码基于Batch Python Quickstart samples and the Batch documentation。
我已经尝试了 Troubleshoot registry login 指南中的各种步骤,但没有效果。我通过 Azure Shell 登录 ACR 没有问题,但这是我的普通用户,当然不是 UAMI。
GUID 已更改以保护无辜者。
哈尔普?
在池中使用托管标识时,您必须将标识添加到池本身,在帐户上设置标识允许批处理服务本身使用标识,但不能使用池中的 VM。请注意,您实际上不需要在您的用例(Azure 容器注册表)中设置帐户身份,只需设置池即可。
请在此处查看有关为池分配身份的文档:
https://docs.microsoft.com/azure/batch/managed-identity-pools
我正在尝试 运行 Ubuntu VM 上的 Azure Batch 任务,其中包含从私有 Azure 容器注册表中提取的映像。池中的节点创建失败并出现以下错误,无论我是否预取:
Code: NodePreparationError
Message:
An error occurred during node preparation
Values:
Error - Hit unexpected error installing containers
Message - 400, message='Bad Request', url=URL('http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/&mi_res_id=/subscriptions/7bd2fd6e-1cb6-4db2-82fe-67c7ea3024cd/resourceGroups/SANDBOX/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my_uami')
基准:我有一个包含资源组的 Azure 订阅。在资源组中是
- 容器注册表,
- 一个批处理帐户,并且
- 用户分配的托管标识。
UAMI 在 Container Registry 和 Batch Account 的身份边栏中分配。管理员为我的订阅分配了 AcrPull
角色。
我可以将图像拉到我的本地机器上,所以我知道它存在。我已经尝试 运行在来自 Docker Hub 的预取 python3.7-slim
图像上执行一个简单的任务并成功了,所以问题出在 Batch 和 ACR 之间。
这是一个演示问题的最小示例:
from azure.batch import BatchServiceClient
from azure.batch.batch_auth import SharedKeyCredentials
from azure.batch.models import (
ComputeNodeIdentityReference,
ContainerConfiguration,
ContainerRegistry,
ImageReference,
JobAddParameter,
PoolAddParameter,
PoolInformation,
VirtualMachineConfiguration,
)
if __name__ == '__main__':
batch_service_client = BatchServiceClient(
SharedKeyCredentials('batchtest2021', 'GZTn…………………………………pGJ+gNE…………………………dvw=='),
batch_url='https://batchtest2021.westeurope.batch.azure.com/',
)
pool_id = 'my_test_pool'
new_pool = PoolAddParameter(
id=pool_id,
virtual_machine_configuration=VirtualMachineConfiguration(
container_configuration=ContainerConfiguration(
container_image_names=[
'myprivateacr.azurecr.io/mydockerimage:latest',
],
container_registries=[
ContainerRegistry(
registry_server='myprivateacr.azurecr.io',
identity_reference=ComputeNodeIdentityReference(
resource_id=f'/subscriptions/7bd2fd6e-1cb6-4db2-82fe-67c7ea3024cd/resourceGroups/SANDBOX/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my_uami'
),
),
],
),
image_reference=ImageReference(
publisher='microsoft-azure-batch',
offer='ubuntu-server-container',
sku='20-04-lts',
version='latest',
),
node_agent_sku_id='batch.node.ubuntu 20.04',
),
vm_size='STANDARD_A2M_V2',
target_dedicated_nodes=2,
)
batch_service_client.pool.add(new_pool)
job = JobAddParameter(id='sample_job_id', pool_info=PoolInformation(pool_id=pool_id))
batch_service_client.job.add(job)
代码基于Batch Python Quickstart samples and the Batch documentation。
我已经尝试了 Troubleshoot registry login 指南中的各种步骤,但没有效果。我通过 Azure Shell 登录 ACR 没有问题,但这是我的普通用户,当然不是 UAMI。
GUID 已更改以保护无辜者。
哈尔普?
在池中使用托管标识时,您必须将标识添加到池本身,在帐户上设置标识允许批处理服务本身使用标识,但不能使用池中的 VM。请注意,您实际上不需要在您的用例(Azure 容器注册表)中设置帐户身份,只需设置池即可。
请在此处查看有关为池分配身份的文档:
https://docs.microsoft.com/azure/batch/managed-identity-pools