Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 2.25 KB

create-managed-disk-from-vhd.md

File metadata and controls

51 lines (33 loc) · 2.25 KB
title description author ms.service ms.devlang ms.topic ms.date ms.author ms.custom
Create a managed disk from a VHD file in the same account - CLI sample
Azure CLI Script Sample - Create a managed disk from a VHD file in a storage account in the same subscription
roygara
azure-disk-storage
azurecli
sample
02/23/2022
rogarana
mvc, devx-track-azurecli, linux-related-content

Create a managed disk from a VHD file in a storage account in the same subscription with CLI (Linux)

This script creates a managed disk from a VHD file in a storage account in the same subscription. Use this script to import a specialized (not generalized/sysprepped) VHD to managed OS disk to create a virtual machine. Or, use it to import a data VHD to managed data disk.

[!INCLUDE quickstarts-free-trial-note]

[!INCLUDE azure-cli-prepare-your-environment.md]

Sample script

[!INCLUDE cli-launch-cloud-shell-sign-in.md]

Run the script

:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/create-managed-data-disks-from-vhd/create-managed-data-disks-from-vhd.sh" id="FullScript":::

Clean up resources

Run the following command to remove the resource group, VM, and all related resources.

az group delete --name myResourceGroupName

Sample reference

This script uses following commands to create a managed disk from a VHD. Each command in the table links to command specific documentation.

Command Notes
az disk create Creates a managed disk using URI of a VHD in a storage account in the same subscription

Next steps

Create a virtual machine by attaching a managed disk as OS disk

For more information on the Azure CLI, see Azure CLI documentation.

Additional virtual machine and managed disks CLI script samples can be found in the Azure Linux VM documentation.