0

有没有办法使用 Azure SDK 将 VHD 上传到 Azure?我知道通过 Powershell 上传它的相同过程(https://docs.microsoft.com/en-us/azure/virtual-machines/windows/classic/createupload-vhd),但我想使用SDK,以便可以使用 Linux 环境执行。

4

2 回答 2

1

根据您的描述,我们可以在您的 Linux 环境中安装 Azure CLI 1.0CLI 2.0 。

关于如何使用CLI 2.0从 Linux 环境上传 VHD,请参考此链接

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

关于如何使用CLI 1.0从您的 Linux 环境上传 VHD,请参考链接

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
于 2017-04-10T01:41:32.323 回答
1

根据您的描述,我认为您想在本地 Linux 上将 VHD 上传到 Azure,就像在 Windows 上通过 powershell 一样。因此,正如通过 Azure CLI 为 Linux 提供的官方教程所说,这就是你想要的。但是,这是一种使用 Azure 服务管理 (ASM) 模式创建 VHD 并将其上传到 Azure 的旧方法。现在,Azure 资源管理 (ARM) 取代了 ASM API。如果要使用 ARM API 创建 VHD,可以参考 REST APICreate a virtual machine image或 Python SDK for Managed Disks.

如果您只是需要将 VHD 从本地上传到 Azure 存储,您只需参考官方教程How to use Azure Blob storage from Python即可。

希望能帮助到你。

于 2017-04-10T07:09:34.590 回答