Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.98k forks source link

az storage blob does not seem to work with a managed disk SAS #17539

Open anish opened 3 years ago

anish commented 3 years ago

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug When using az storage blob upload to upload a vhd to a managed disk using SAS uri, upload to blob completes but is never imported as disk

To Reproduce

az disk create -n test-disk -g aim-pipeline -l westus2 --for-upload --upload-size-bytes 8589935104 --sku standard_lrs --os-type Linux --hyper-v-generation V2
az disk grant-access -n test-disk -g aim-pipeline --access-level Write --duration-in-seconds 86400

az storage account keys list -g aim-pipeline -n aimpipelinestorage --query "[?keyName=='key1'] | [0].value" -o tsv
az storage blob upload -c aimstoragecontainer -f ./test.vhd -n test --account-name aimpipelinestorage --account-key "+kz....Xg==" --sas-token "sv=2018-03-28&....ss%3D" -t page

Expected behavior az disk list will show a non null size for disk

Environment summary apt-get install on Ubuntu 20.04

Additional context I already verified the vhd works, so does the blob upload, I am able to create a disk directly via this command az disk create -n test-disk2 -g aim-pipeline -l westus2 --source https://aimpipelinestorage.blob.core.windows.net/aimstoragecontainer/test --sku standard_lrs --hyper-v-generation V2 --os-type Linux

but unable to upload a vhd directly to a disk created with --for-upload

This looks like it's quite related to #10192 which was closed but no update was provided

yonzhan commented 3 years ago

Storage

Juliehzl commented 3 years ago

Hi @anish, it is because disk is not normal storage account. To upload to the link, there are two options:

  1. az storage copy to upload with destination url
  2. Install storage-blob-preview extension and then upload with --blob-url in az storage blob upload command
anish commented 3 years ago

@Juliehzl is there an example of using az storage copy to upload a vhd to a managed disk ? I don't see any example here, https://docs.microsoft.com/en-us/cli/azure/storage?view=azure-cli-latest#az_storage_copy

is this correct ? az storage copy -s path/to/test.vhd --destination-account-name aimpipelinestorage --destination-container aimstoragecontainer --account-key "+kz....Xg==" --sas-token "sv=2018-03-28&....ss%3D" -blob-type PageBlob