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
How Socially Responsible Investing Connects to Your Values
How to invest in making buildings green: Five fund and trust tips
Ohio Houses With Land for Sale - 1,591 Properties
Uihc Family Medicine
Kokichi's Day At The Zoo
Www.metaquest/Device Code
What Auto Parts Stores Are Open
Retro Ride Teardrop
Bloxburg Image Ids
Skip The Games Norfolk Virginia
Katie Boyle Dancer Biography
Which aspects are important in sales |#1 Prospection
Mndot Road Closures
LeBron James comes out on fire, scores first 16 points for Cavaliers in Game 2 vs. Pacers
What Is A Good Estimate For 380 Of 60
George The Animal Steele Gif
Springfield Mo Craiglist
Conan Exiles Thrall Master Build: Best Attributes, Armor, Skills, More
2016 Ford Fusion Belt Diagram
Becu Turbotax Discount Code
Arboristsite Forum Chainsaw
Blackwolf Run Pro Shop
Swedestats
Where to Find Scavs in Customs in Escape from Tarkov
Buy Swap Sell Dirt Late Model
Pay Boot Barn Credit Card
Loves Employee Pay Stub
Popular Chinese Restaurant in Rome Closing After 37 Years
Veracross Login Bishop Lynch
Vegas7Games.com
Espn Horse Racing Results
Jeffers Funeral Home Obituaries Greeneville Tennessee
Ticket To Paradise Showtimes Near Cinemark Mall Del Norte
Lininii
140000 Kilometers To Miles
Gasbuddy Lenoir Nc
To Give A Guarantee Promise Figgerits
Oxford Alabama Craigslist
Mcgiftcardmall.con
Sept Month Weather
Entry of the Globbots - 20th Century Electro​-​Synthesis, Avant Garde & Experimental Music 02;31,​07 - Volume II, by Various
Craigslist - Pets for Sale or Adoption in Hawley, PA
Go Bananas Wareham Ma
At Home Hourly Pay
R: Getting Help with R
Kenwood M-918DAB-H Heim-Audio-Mikrosystem DAB, DAB+, FM 10 W Bluetooth von expert Technomarkt
Upcoming Live Online Auctions - Online Hunting Auctions
Bama Rush Is Back! Here Are the 15 Most Outrageous Sorority Houses on the Row
Wrentham Outlets Hours Sunday
28 Mm Zwart Spaanplaat Gemelamineerd (U999 ST9 Matte | RAL9005) Op Maat | Zagen Op Mm + ABS Kantenband
Www Extramovies Com
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.