Azure SDK を使用して Azure に VHD をアップロードする方法はありますか? Powershell ( https://docs.microsoft.com/en-us/azure/virtual-machines/windows/classic/createupload-vhd )を介してアップロードする同じプロセスを認識していますが、使用してそれを達成したいと思いますLinux 環境を使用して実行できるように、SDK を使用します。
2 に答える
説明に従って、Azure CLI 1.0またはCLI 2.0を Linux 環境にインストールできます。
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
あなたの説明によると、PowerShell を介して Windows で行うのと同じように、VHD をローカル Linux の Azure にアップロードしたいと考えています。したがって、 Azure CLI を介した Linux の公式チュートリアルで述べたように、それはあなた次第です。ただし、Azure サービス管理 (ASM) モードを使用して VHD を作成し、Azure にアップロードするのは古い方法です。現在、ASM API の代わりに Azure Resource Management (ARM) がありました。Create a virtual machine image
ARM API を使用して VHD を作成する場合は、REST APIまたは Python SDK forを参照できますManaged Disks
。
VHD をローカルから Azure Storage にアップロードするだけでよい場合は、公式のチュートリアルHow to use Azure Blob storage from Python
を参照してください。
それが役に立てば幸い。