Attach an unmanaged disk to a VM for offline repair - Virtual Machines (2024)

  • Article

Applies to: ✔️ Windows VMs

Some troubleshooting scenarios for Windows virtual machines (VMs), such as when a VM doesn't start, require you to repair its OS disk offline. This article describes how you can perform this kind of offline repair when the failed OS disk is unmanaged.

Determine if the OS disk is managed or unmanaged

Azure portal

Open the Overview blade for the VM. If the OS disk is unmanaged, an informational banner indicates that the VM is not using managed disks.

Attach an unmanaged disk to a VM for offline repair - Virtual Machines (1)

In addition, the Overview blade for the OS disk appends "(unmanaged)" to the disk name if the disk is unmanaged, as shown below:

Attach an unmanaged disk to a VM for offline repair - Virtual Machines (2)

If the disk is managed, the Overview blade for the OS disk displays a Managed by field, as shown below:

Attach an unmanaged disk to a VM for offline repair - Virtual Machines (3)

PowerShell

You can verify that the OS disk is unmanaged by entering the following command. (Be sure to replace "MyResourceGroup" with the name of your resource group and "MyVM" with the name of your VM.)

(get-azvm -ResourceGroupName MyResourceGroup -Name MyVM).StorageProfile.OsDisk

If the disk is unmanaged, no value appears in the output next to ManagedDisk, as in the following example:

OsType : WindowsEncryptionSettings :Name : MyVM-Disk1Vhd : Microsoft.Azure.Management.Compute.Models.VirtualHardDiskImage :Caching : ReadWriteWriteAcceleratorEnabled :DiffDiskSettings :CreateOption : FromImageDiskSizeGB : 127ManagedDisk :

If the disk is a managed disk, you will see a value in the output next to ManagedDisk, as in the following example:

OsType : WindowsEncryptionSettings :Name : MyVM2-Disk1Vhd :Image :Caching : ReadWriteWriteAcceleratorEnabled :DiffDiskSettings :CreateOption : FromImageDiskSizeGB :ManagedDisk : Microsoft.Azure.Management.Compute.Models.ManagedDiskParameters

Azure command-line interface (Azure CLI)

You can use the az vm show command with the appended query "storageProfile.osDisk.managedDisk" to determine whether the disk has managed disks, as in the following example:

az vm show -n MyVM -g MyResourceGroup --query "storageProfile.osDisk.managedDisk"

If the disks are unmanaged, the command will generate no output. If the disks are managed, it will generate output like in the following example:

{ "diskEncryptionSet": null, "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/disks/MyVm_OsDisk_1", "resourceGroup": "MyResourceGroup", "storageAccountType": null}

Create a copy of the unmanaged OS disk attached to the source (failed) VM

  1. In the Azure portal, stop the source VM whose OS disk is unmanaged.

  2. On your local computer, download, install, and then start Microsoft Azure Storage Explorer. Supply your Azure credentials when you're prompted.

  3. In the Storage Explorer navigation pane, expand the appropriate subscription.

  4. Select the storage account in which the VHD is located, and then select the appropriate container for the disk. By default, unmanaged OS disks are stored in the vhds (Leased) container.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (4)

  5. In the right pane, select the VHD that's attached to the source VM that you want to repair, and then select Copy at the top. Notice that the copied disk can be pasted only into a different blob container.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (5)

  6. Create a new blob container by right-clicking Blob Container in the navigation pane, and then selecting Create Blob Container. Assign the new blob container a name of your choice, such as "disk-copies."

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (6)

  7. Select Paste to paste the copied disk into the new blob container.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (7)

Create a repair VM with an unmanaged OS disk

  1. In the Azure portal, begin the process of creating a new VM that's based on Windows Server 2019.This new VM will act as your repair VM, and its own OS disk must be unmanaged.

  2. On the Basics page of the "Create a Virtual Machine" wizard, select No infrastructure redundancy required in the Availability options list.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (8)

  3. On the Disks page, expand Advanced below Data Disks and then clear the Use managed disks check box. Select a storage account for the unmanaged OS disk. Do not select to attach an existing disk.Attach an unmanaged disk to a VM for offline repair - Virtual Machines (9)If the Use managed disks option cannot be unselected, try to create the VM by using the following commands:

    ## Get the subnet ID of the VM$SubnetID = az network vnet subnet show --resource-group <RG name> --name <Subnet name> --vnet-name <VNet name> --query id -o tsv## Create a VM with the unmanaged diskaz vm create \ --resource-group <RG name>\ --name <VM name>\ --image <Image name>\ --location <location of the VM>\ --admin-username <Admin name>\ --subnet $SubnetID\ --size <VM size>\ --use-unmanaged-disk 
  4. Complete the "Create a Virtual Machine" wizard by specifying configuration details that are appropriate for your organization.

Attach a copy of the unmanaged disk to the repair VM

  1. In the Azure portal, open the Disks blade for the new repair VM that you just created.

  2. Select + Add data disk.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (10)

  3. On the Attach Unmanaged Disk page, select Existing blob as the Source type.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (11)

  4. Beneath Source blob, select Browse, and then browse to select the OS disk copy that you created earlier.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (12)

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (13)

  5. On the Attach Unmanaged Disk page, accept the default storage blob name, and then select OK.

  6. On the Disks blade of the new repair VM, select Save.

    Attach an unmanaged disk to a VM for offline repair - Virtual Machines (14)

Unlock the disk if it is encrypted

If the disk is encrypted with Azure Disk Encryption (ADE), you will need to unlock it before you can repair it. To do so, use the steps described in Resolution #3: Manual method to unlock an encrypted disk on a repair VM.

You can determine if the disk is encrypted by using the procedure here: Confirm that ADE is enabled on the disk

Replace the OS disk on the source VM

After you finish repairing the disk, follow these steps:

  1. Detach the source VM OS disk by using either Azure CLI or PowerShell.

    Azure CLI

    Use the az vm unmanaged-disk detach command, as in the following example:

    az vm unmanaged-disk detach -g MyResourceGroup --vm-name MyVm -n disk_name

    PowerShell

    Enter the following commands in Azure Cloud Shell, one at time:

    $VirtualMachine = Get-AzVM -ResourceGroupName "MyResourceGroup" -Name "MyVm" Remove-AzVMDataDisk -VM $VirtualMachine -Name "disk_name"Update-AzVM -ResourceGroupName "MyResourceGroup" -VM $VirtualMachine

    After you detach the disk, you can replace the OS disk on the source VM.

  2. When the prompt returns, open a text editor, such as Notepad, and record the following values:

    • Subscription ID ($subscriptionID): The 32-digit globally unique identifier (GUID) that's associated with your Azure subscription.
    • Resource group name ($rgname): The resource group of the source VM.
    • VM name ($vmname): The name of the source (failed) VM.
    • OS disk VHD URI ($vhduri): The URI of the copy of the unmanaged OS Disk that you just detached from the repair VM. (You can copy this value by right-clicking the disk in Storage Explorer and then selecting Copy URL.)
  3. Enter the following commands at the PowerShell command prompt in Azure Cloud Shell, one at a time. In each command, replace the values "Subscription ID," "Resource group name," "VM name," and "OS disk VHD URI" with the corresponding values that you just recorded from your environment.

    $subscriptionID = "Subscription ID"$rgname = "Resource group name"$vmname = "VM Name"$vhduri = "OS disk VHD URI"#Add-AzAccountSelect-AzSubscription -SubscriptionID $subscriptionIDSet-AzContext -SubscriptionID $subscriptionID$vm = Get-AzVM -ResourceGroupName $rgname -Name $vmname$vm.StorageProfile.OsDisk.Vhd.Uri = $vhduriUpdate-AzVM -ResourceGroupName $rgname -VM $vm 

    After the operation finishes, you should see the following output:

    RequestId IsSuccessStatusCode StatusCode ReasonPhrase--------- ------------------- ---------- ------------ True OK OK
  4. In Azure portal, open the Disks blade on the VM. Select the OS disk, and then verify that the VHD URI matches the value you supplied in the last step.

Next Steps

To read an overview of ADE, see Enable Azure Disk Encryption for Windows VMs.For more information about commands you can use to manage unmanaged disks, see az vm unmanaged-disk.

If you have questions or need help, create a support request, or ask Azure community support. You can also submit product feedback to Azure feedback community.

Attach an unmanaged disk to a VM for offline repair - Virtual Machines (2024)
Top Articles
What To Do When Your Baby Wants to Be Held All. the. Time.
Where to get a $6,000 loan
Rubratings Tampa
Tmf Saul's Investing Discussions
Time in Baltimore, Maryland, United States now
Spn 1816 Fmi 9
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
Mndot Road Closures
Day Octopus | Hawaii Marine Life
Ktbs Payroll Login
Zendaya Boob Job
How Many Cc's Is A 96 Cubic Inch Engine
Cooktopcove Com
This Modern World Daily Kos
Costco Gas Foster City
Are They Not Beautiful Wowhead
Www Craigslist Milwaukee Wi
Recap: Noah Syndergaard earns his first L.A. win as Dodgers sweep Cardinals
Zack Fairhurst Snapchat
Lakers Game Summary
Walmart Near South Lake Tahoe Ca
Woodmont Place At Palmer Resident Portal
Boston Dynamics’ new humanoid moves like no robot you’ve ever seen
Hannaford Weekly Flyer Manchester Nh
Kohls Lufkin Tx
Ltg Speech Copy Paste
Jackie Knust Wendel
Inter Miami Vs Fc Dallas Total Sportek
4Oxfun
WRMJ.COM
Cable Cove Whale Watching
Giantbodybuilder.com
UAE 2023 F&B Data Insights: Restaurant Population and Traffic Data
Ryujinx Firmware 15
Craigslist Scottsdale Arizona Cars
Elanco Rebates.com 2022
Taktube Irani
Ultra Clear Epoxy Instructions
Ducky Mcshweeney's Reviews
#1 | Rottweiler Puppies For Sale In New York | Uptown
Weapons Storehouse Nyt Crossword
Ticket To Paradise Showtimes Near Regal Citrus Park
Hazel Moore Boobpedia
Weekly Math Review Q2 7 Answer Key
Bonecrusher Upgrade Rs3
New Zero Turn Mowers For Sale Near Me
25100 N 104Th Way
Craigslist Anc Ak
Unpleasant Realities Nyt
Poster & 1600 Autocollants créatifs | Activité facile et ludique | Poppik Stickers
What your eye doctor knows about your health
Primary Care in Nashville & Southern KY | Tristar Medical Group
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 6596

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.