The VM with unmanaged disks.
The following cmndlet can be used to take snapshot of a managed disk (ARM)
$snapshot = New-AzureRmSnapshotConfig
-SourceUri $vm.StorageProfile.OsDisk.ManagedDisk.Id
-Location $location `
-CreateOption copy
How can this be done for a vm with unmanaged disk ?
Asked
Active
Viewed 433 times
0

Eddie Chen - MSFT
- 29,708
- 2
- 46
- 60

twinkle hema
- 75
- 1
- 11
-
for unmanaged disk just copy the underlying vhd? – 4c74356b41 Oct 05 '18 at 05:18
-
SourceUri $vm.StorageProfile.OsDisk.vhd do you mean this @4c74356b41 ?I did that but I got an error saying invalid source id. – twinkle hema Oct 05 '18 at 05:20
1 Answers
0
http://www.brainscale.com/blogs/azure-arm-vm-snapshot/ like so you could snapshot the underlying storage, you can also use UI to create managed disk or you can create a managed disk from the vhd.
#Provide the subscription Id where Managed Disks will be created
$subscriptionId = 'yourSubscriptionId'
#Provide the name of your resource group where Managed Disks will be created.
$resourceGroupName ='yourResourceGroupName'
#Provide the name of the Managed Disk
$diskName = 'yourDiskName'
#Provide the size of the disks in GB. It should be greater than the VHD file size.
$diskSize = '128'
#Provide the storage type for Managed Disk. PremiumLRS or StandardLRS.
$storageType = 'PremiumLRS'
#Provide the Azure region (e.g. westus) where Managed Disk will be located.
#This location should be same as the storage account where VHD file is stored
#Get all the Azure location using command below:
#Get-AzureRmLocation
$location = 'westus'
#Provide the URI of the VHD file (page blob) in a storage account. Please not that this is NOT the SAS URI of the storage container where VHD file is stored.
#e.g. https://contosostorageaccount1.blob.core.windows.net/vhds/contosovhd123.vhd
#Note: VHD file can be deleted as soon as Managed Disk is created.
$sourceVHDURI = 'https://contosostorageaccount1.blob.core.windows.net/vhds/contosovhd123.vhd'
#Provide the resource Id of the storage account where VHD file is stored.
#e.g. /subscriptions/6472s1g8-h217-446b-b509-314e17e1efb0/resourceGroups/MDDemo/providers/Microsoft.Storage/storageAccounts/contosostorageaccount
#This is an optional parameter if you are creating managed disk in the same subscription
$storageAccountId = '/subscriptions/yourSubscriptionId/resourceGroups/yourResourceGroupName/providers/Microsoft.Storage/storageAccounts/yourStorageAccountName'
#Set the context to the subscription Id where Managed Disk will be created
Select-AzureRmSubscription -SubscriptionId $SubscriptionId
$diskConfig = New-AzureRmDiskConfig -AccountType $storageType -Location $location -CreateOption Import -StorageAccountId $storageAccountId -SourceUri $sourceVHDURI
New-AzureRmDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName
and snapshot it after. Source. Not sure, but snapshots might not be available for unmanaged disks (dont quote me on this).

4c74356b41
- 69,186
- 6
- 100
- 141