azure-blob-storageqemuazure-storage-accountvhd

ERROR: Invalid page blob size: 167816. The size must be aligned to a 512-byte boundary


I have a VHD disk created using qemu-img, and using qemu-img, I see the size as

vmdkDisk="xxxxxxx-disk1.vmdk"
vhdDisk="xxxxxxx-disk1.vhd"
qemu-img convert -f vmdk -O qcow2 $vmdkDisk image.qcow2
# -- resize raw image
qemu-img resize -f raw image.qcow2 8g
# -- convert raw disk to  VHD
qemu-img convert -f raw -o subformat=fixed,force_size -O vpc image.qcow2 $vhdDisk


qemu-img info -f vpc --output json xxxxxxx-disk1.vhd
{
    "virtual-size": 8589934592,
    "filename": "xxxxxxx-disk1.vhd",
    "format": "vpc",
    "actual-size": 5870948352,
    "dirty-flag": false
}

so I understand the virtual size in MB is 8589934592/1024/1024=8192MB

however, when I tried to upload the VHD to azure storage container, I got the following error

az storage blob upload-batch --account-name yyyy \
--account-key 0000000== \
--destination vhd --source . --type  page

1/2: "xxxxxxx-disk1.vhd"[#####################]  100.0000%ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: Invalid page blob size: 167816. The size must be aligned to a 512-byte boundary.
Traceback (most recent call last):
  File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_job
    return cmd_copy.exception_handler(ex)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/__init__.py", line 412, in new_handler
    first(ex)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/__init__.py", line 412, in new_handler
    first(ex)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/_exception_handler.py", line 17, in file_related_exception_handler
    raise ex
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 527, in storage_blob_upload_batch
    include, result = _upload_blob(cmd, blob_client, file_path=src,
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/util.py", line 311, in wrapper
    return True, func(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 509, in _upload_blob
    return upload_blob(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/cli/command_modules/storage/operations/blob.py", line 633, in upload_blob
    response = client.upload_blob(data=stream, length=length, metadata=metadata,
  File "/opt/az/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 73, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/opt/az/lib/python3.10/site-packages/azure/multiapi/storagev2/blob/v2021_06_08/_blob_client.py", line 730, in upload_blob
    return upload_page_blob(**options)
  File "/opt/az/lib/python3.10/site-packages/azure/multiapi/storagev2/blob/v2021_06_08/_upload_helpers.py", line 201, in upload_page_blob
    raise ValueError("Invalid page blob size: {0}. "
ValueError: Invalid page blob size: 167816. The size must be aligned to a 512-byte boundary.
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
To open a new issue, please run `az feedback`

If I tried to 167816/512= 327.765625, so it is indeed not an integer.

however, how is this blob size calcualated here?

thanks!


Solution

  • az storage blob upload-batch --account-name yyyy \
    --account-key 0000000== \
    --destination vhd --source . --type  page \
    --pattern *.vhd
    

    I forgo to add the file pattern filter and azcli uploading the nohup logs together with vhd, which caused the error.