Powershell script to create OS disk in azure from storage account blob image file (vhd)
#Provide the subscription Id where Managed Disks will be created
$subscriptionId = 'd7x2bxx8-62xe-4xdx-xa8x-20x0x3x2x5xx'
#Provide the name of your resource group where Managed Disks will be created.
#Provide the name of the Managed Disk
$diskName = 'Project_Disk2'
#Provide the size of the disks in GB. It should be greater than the VHD file size.
$diskSize = '90'
#Provide the storage type for Managed Disk. PremiumLRS or StandardLRS.
$storageType = 'Premium_LRS'
#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:
$location = 'ukwest'
#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.
#Note: VHD file can be deleted as soon as Managed Disk is created.
$sourceVHDURI = 'https://sanjeebojha.blob.core.windows.net/myproject/myoriginalVM.vhd'
#Provide the resource Id of the storage account where VHD file is stored.
#This is an optional parameter if you are creating managed disk in the same subscription
$storageAccountId = '/subscriptions/d7x2bxx8-62xe-4xdx-xa8x-20x0x3x2x5xx/resourceGroups/MYResourceGroupName/providers/Microsoft.Storage/storageAccounts/sanjeebojha'
#Set the context to the subscription Id where Managed Disk will be created
Select-AzSubscription -SubscriptionId $SubscriptionId
$diskConfig = New-AzDiskConfig -AccountType $storageType -OsType Windows -Location $location -CreateOption Import -StorageAccountId $storageAccountId -SourceUri $sourceVHDURI
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName