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]
[!INCLUDE cli-launch-cloud-shell-sign-in.md]
:::code language="azurecli" source="~/azure_cli_scripts/virtual-machine/create-managed-data-disks-from-vhd/create-managed-data-disks-from-vhd.sh" id="FullScript":::
Run the following command to remove the resource group, VM, and all related resources.
az group delete --name myResourceGroupName
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 |
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.