Azure批处理池创建错误,说请求主体的格式对于自定义映像无效

问题描述

我正在使用以下命令创建一个Azure批处理池。请注意,我正在使用自定义图像。另外请注意,我已经通过Active Directory对批次进行了身份验证:

az batch pool create --json-file pool.json

pool.json文件如下所示

{
"id": "WEPool004","vmSize": "Standard_NC6","virtualMachineConfiguration": {
    "imageReference": {
        "virtual_machine_image_id": "/subscriptions/{sub id}/resourceGroups/{resource group name}/providers/Microsoft.Compute/images/{image deFinition name}","publisher": null,"offer": null,"sku": null
    },"nodeAgentSKUId": "batch.node.ubuntu 18.04"
},"targetDedicatednodes": 1

}

Azure CLI抱怨错误

Reason: The specified resource id must be of the format /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName} or /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}

现在,这意味着this页已过时,因为我遵循了它们的格式。 如果我遵循错误中指定的格式,则需要制作图片库,然后再进行图片定义。如果我确实做了这两个,然后替换了virtual_machine_image_id,则它在Azure命令行界面上没有抱怨,但是在Azure门户的“池”页面上,它显示以下错误消息:

Message:
Desired number of dedicated nodes Could not be allocated

Values:
Reason - The specified image is not found

所以我遇到了错误信息virtual_machine_image_id格式无效,或者根本找不到它。因此,我可以假设在进行图像定义和图库时出现错误。请谁能指出我正确的方向。 请注意,我已按照this教程进行了Azure CLI批处理。

解决方法

我犯的错误是我没有创建快照。我使用了根据此tutorial中指定的使用快照创建的图像定义中的URL。现在可以正常工作了。