Сообщение: обязательный параметр 'hyperVGeneration' отсутствует (ноль) при создании образа управляемого диска из хранилища BLOB-объектов - PullRequest
0 голосов
/ 01 августа 2020
  • Имя пакета : 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

Если кто-нибудь нашел обходной путь для этого, поделитесь пожалуйста ....

1 Ответ

1 голос
/ 03 августа 2020

Я могу воспроизвести вашу проблему, чтобы исправить ее, нам нужно добавить 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)

введите описание изображения здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...