I was doing migration yesterday from on-prem to Azure with the help of one of the Image replication tool and everything was going as planned until that replication tool got failed in between but when i checked manually all the disk and VM was already been created on Azure. I thought rather calling for support why not work with what all replicated on Azure and my only problem was not all the disk was attached as it should be because as i mentioned it got failed after running half of the process.
So rather getting into the details and messed up the situation , lets talk what are we going to do in this post, as per situation i needed to create OS-disk from snapshot so that i could spin VM & here are the PS code that i used for it and worked as charm -
$resourceGroupName = "your RG"
$snapshotName = "Name of snapshot"
$storageType = "storage type for managed disk"
$location = "Location"
$diskName = "your disk name"
$snapshot = Get-AzSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName
$diskConfig = New-AzDiskConfig -AccountType $storageType -Location $location -CreateOption Copy -SourceResourceId $snapshot.Id -OsType Windows
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName
Above code worked as expected and i could create the os-disk and created VM out of it.
So rather getting into the details and messed up the situation , lets talk what are we going to do in this post, as per situation i needed to create OS-disk from snapshot so that i could spin VM & here are the PS code that i used for it and worked as charm -
$resourceGroupName = "your RG"
$snapshotName = "Name of snapshot"
$storageType = "storage type for managed disk"
$location = "Location"
$diskName = "your disk name"
$snapshot = Get-AzSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName
$diskConfig = New-AzDiskConfig -AccountType $storageType -Location $location -CreateOption Copy -SourceResourceId $snapshot.Id -OsType Windows
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName
Above code worked as expected and i could create the os-disk and created VM out of it.
No comments:
Post a Comment