
Update-AzureRmVM -VM $VM -ResourceGroupName $resourceGroupNameĪzure Engineer and Microsoft Certified Trainer. $NewDisk = Get-AzureRmDisk -ResourceGroupName $resourceGroupName | Where-Object | Select-Object name, id

$VM = Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name "VMtoRestore" Remove-AzureRmSnapshot -ResourceGroupName $ResourceGroupName -SnapshotName $SnapshotName -Force # you have disk so you dont need snapshot New-AzureRmDisk -Disk $DiskConfig -ResourceGroupName $ResourceGroupName -DiskName $NewDiskName $DiskConfig = New-AzureRmDiskConfig -AccountType $StorageType -Location $location -CreateOption Copy -SourceResourceId $Snapshot.Id

$Snapshot = Get-AzureRmSnapshot -ResourceGroupName $ResourceGroupName -SnapshotName $SnapshotName Since there would be no activity on the disks, the snapshot process will keep the data intact without risks of open files. When performing a snapshot, the recommendation is to stop the VM first. New-AzureRmSnapshot -Snapshot $Snapshot -SnapshotName $SnapshotName -ResourceGroupName $ResourceGroupNameĬreate Managed Disk from Snapshot $StorageType = "PremiumLRS" # if you need hdd use StandardLRS A snapshot is a read-only copy of a virtual hard drive (also known as VHD). $Snapshot = New-AzureRmSnapshotConfig -SourceUri $Disk.Id -CreateOption Copy -Location $location $Disk = Get-AzureRmDisk -ResourceGroupName $resourceGroupName -Name "osdisk" Azure Real-World -Training Azure - Create a VM Snapshot 9,491 views 101 Dislike Share Save ROCITWORKS 3.57K subscribers Azure - Create a VM Snapshot Show more 4.5K views Tech. Stop-AzureRmVM -ResourceGroupName $resourceGroupName -Name "VMtoRestore" Shutdown Virutal Machine $resourceGroupName = "TestGroup" Why not just replace OS disk? Let's start from the beginning. Follow the steps below to set up an Azure VM disk space alert in the Azure portal. Variables.At the moment official way to restore Virtual Machine from a snapshot is to recreate VM. Resource_group_name = data.azurerm_managed_disk.existing


Below is the necessary files.įor_each = zipmap(var.cloud_resource_group_list,var.cloud_vm_os_disk_name)įor_each = () I have created two lists with resource group details and OS Disk name. I have written a small terraform script to take snapshot of two VM’s sitting on Azure.
