0
  • 包名称:azure.mgmt.compute
  • 包版本:v2020_06_01
  • 操作系统:ubuntu 18.04
  • Python版本:Python 3.7

描述错误 而不是创建磁盘它会引发Message: Required parameter 'hyperVGeneration' is missing (null). 错误。

重现行为的重现 步骤:

  1. 运行以下代码
compute_client = get_client_from_cli_profile(ComputeManagementClient)
async_creation = compute_client.images.create_or_update(
    '7AQVDL2J',
    'test',
    {
        'location': 'westeurope',
        'storage_profile': {
           'os_disk': {
              'os_type': 'Linux',
              'os_state': "Generalized",
              'blob_uri': 'https://bg09.blob.core.windows.net/vm-images/non-existent.vhd',
              'caching': "ReadWrite",
           }
        }
    }
) 

应创建的预期行为磁盘

错误

 Traceback (most recent call last):
  File "<stdin>", line 11, in <module>
  File "/usr/local/lib/python3.7/dist-packages/azure/mgmt/compute/v2020_06_01/operations/_images_operations.py", line 125, in create_or_update
    **operation_config
  File "/usr/local/lib/python3.7/dist-packages/azure/mgmt/compute/v2020_06_01/operations/_images_operations.py", line 81, in _create_or_update_initial
    raise exp
msrestazure.azure_exceptions.CloudError: Azure Error: InvalidParameter
Message: Required parameter 'hyperVGeneration' is missing (null).
Target: hyperVGeneration

链接到 git 问题:https ://github.com/Azure/azure-sdk-for-python/issues/12762

如果有人找到解决方法,请分享....

4

1 回答 1

1

我可以重现您的问题,要解决它,我们需要hyper_vgeneration在您创建图像时添加一个。

您可以参考下面的示例,它对我来说很好用。

from azure.mgmt.compute.models import DiskCreateOption
from azure.mgmt.compute import ComputeManagementClient
from azure.common.client_factory import get_client_from_cli_profile

compute_client = get_client_from_cli_profile(ComputeManagementClient)
async_creation = compute_client.images.create_or_update(
    'groupname',
    'test123',
    {
        'location': 'eastus',
        'storage_profile': {
           'os_disk': {
              'os_type': 'Linux',
              'os_state': "Generalized",
              'blob_uri': 'https://joystoragev2.blob.core.windows.net/vhds2/destDisk.vhd',
              'caching': "ReadWrite",
           }
        },
        'hyper_vgeneration': 'V1'
    }
)
image_resource = async_creation.result()
print(image_resource)

在此处输入图像描述

于 2020-08-03T07:30:55.093 回答