Reputation: 498
Is there a way to upload a VHD to Azure using the Azure SDK? I am aware of the same process for uploading it via Powershell (https://learn.microsoft.com/en-us/azure/virtual-machines/windows/classic/createupload-vhd) , but I would like to achieve that using the SDK, so that it can be performed using a Linux environment.
Upvotes: 0
Views: 517
Reputation: 24148
According to your description, I think you want to upload a VHD to Azure on local Linux like do it on Windows via powershell. So as the offical tutorial said for Linux via Azure CLI, it's you wanna. However, it's an old way to create and upload a VHD to Azure using Azure Service Management (ASM) Mode. Now, Azure Resource Management (ARM) had instead of ASM APIs. If you want to create a VHD using ARM API, you can refer to the REST API Create a virtual machine image
or Python SDK for Managed Disks
.
If you just need to upload a VHD from local to Azure Storage, you only refer to the offical tutorial How to use Azure Blob storage from Python
to do it.
Hope it helps.
Upvotes: 1
Reputation: 13974
According to your description, we can install Azure CLI 1.0 or CLI 2.0 on your Linux environment.
About how to use CLI 2.0 to upload VHD from Linux environment, please refer to this link.
az group create --name myResourceGroup --location westus
az storage account create --resource-group myResourceGroup --location westus --name mystorageaccount --kind Storage --sku Standard_LRS
az storage account keys list --resource-group myResourceGroup --account-name mystorageaccount
az storage container create --account-name mystorageaccount --account-key key1 --name mydisks
az storage blob upload --account-name mystorageaccount --account-key key1 --container-name mydisks --type page --file /path/to/disk/mydisk.vhd --name myDisk.vhd
About how to use CLI 1.0 to upload VHD from your Linux environment, please refer to the link.
azure config mode arm
azure group create myResourceGroup --location "WestUS"
azure storage account create mystorageaccount --resource-group myResourceGroup --location "WestUS" --kind Storage --sku-name PLRS
azure storage account keys list mystorageaccount --resource-group myResourceGroup
azure storage container create --account-name mystorageaccount --account-key key1 --container myimages
azure storage blob upload --blobtype page --account-name mystorageaccount --account-key key1 --container myimages /path/to/disk/mydisk.vhd
Upvotes: 1