Well this was fun , We could easily create VM from Portal if we have disk already & i have done it so many times until i encounter this scenario which made me go through PS code twice and fortunately i could figure out what the problem is & why "create VM" is grayed out.
here the picture for you all and you could relate now -
Once you look at the picture you could see Create VM is grayed out and if you look again you will find Operating System option is also blank that is the issue which is not allowing disk to create VM.
If i will be more accurate , Azure is treating this Disk as Data disk not OS Disk hence there is no Option or grayed out option for Create VM.
Resolution : It can easily be fixed if you add one more command in your PS Code .i.e -OsType
below is the code to create disk from VHD and we have selected -OsType Windows that helped us to fix the problem.
$storageType = 'Premium_LRS'
$location = "Central Us"
$storageAccountId = 'youstoragaeaccountID'
$sourceVHDURI = "yourvhduri"
$resourceGroupName = 'RG'
$diskName = 'yourdiskname'
$diskConfig = New-AzDiskConfig -AccountType $storageType -Location $location -CreateOption Import -StorageAccountId $storageAccountId -SourceUri $sourceVHDURI -OsType Windows
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName
Second Resolution is creating VM with the help PS Code , only then you could utilize this disk & below is the code that would help you -
$resourceGroupName = " name of your resource group"
$diskName = " name of the Managed Disk "
$location = " location should be same as the Managed Disk location"
$virtualNetworkName = " name of an existing virtual network where virtual machine will be created"
$virtualMachineName = " name of the virtual machine"
$virtualMachineSize = '' Size available in region and required"
$disk = Get-AzDisk -ResourceGroupName $resourceGroupName -DiskName $diskName
$VirtualMachine = New-AzVMConfig -VMName $virtualMachineName -VMSize $virtualMachineSize
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -ManagedDiskId $disk.Id -CreateOption Attach -Windows
#Create a public IP for the VM (optional)
$publicIp = New-AzPublicIpAddress -Name ($VirtualMachineName.ToLower()+'_ip') -ResourceGroupName $resourceGroupName -Location $location -AllocationMethod Dynamic
$vnet = Get-AzVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $nic.Id
New-AzVM -VM $VirtualMachine -ResourceGroupName $resourceGroupName -Location $location
Hope this post would save you some time and helped you fixing your issue.
here the picture for you all and you could relate now -
Once you look at the picture you could see Create VM is grayed out and if you look again you will find Operating System option is also blank that is the issue which is not allowing disk to create VM.
If i will be more accurate , Azure is treating this Disk as Data disk not OS Disk hence there is no Option or grayed out option for Create VM.
Resolution : It can easily be fixed if you add one more command in your PS Code .i.e -OsType
below is the code to create disk from VHD and we have selected -OsType Windows that helped us to fix the problem.
$storageType = 'Premium_LRS'
$location = "Central Us"
$storageAccountId = 'youstoragaeaccountID'
$sourceVHDURI = "yourvhduri"
$resourceGroupName = 'RG'
$diskName = 'yourdiskname'
$diskConfig = New-AzDiskConfig -AccountType $storageType -Location $location -CreateOption Import -StorageAccountId $storageAccountId -SourceUri $sourceVHDURI -OsType Windows
New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName
Second Resolution is creating VM with the help PS Code , only then you could utilize this disk & below is the code that would help you -
$resourceGroupName = " name of your resource group"
$diskName = " name of the Managed Disk "
$location = " location should be same as the Managed Disk location"
$virtualNetworkName = " name of an existing virtual network where virtual machine will be created"
$virtualMachineName = " name of the virtual machine"
$virtualMachineSize = '' Size available in region and required"
$disk = Get-AzDisk -ResourceGroupName $resourceGroupName -DiskName $diskName
$VirtualMachine = New-AzVMConfig -VMName $virtualMachineName -VMSize $virtualMachineSize
$VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -ManagedDiskId $disk.Id -CreateOption Attach -Windows
#Create a public IP for the VM (optional)
$publicIp = New-AzPublicIpAddress -Name ($VirtualMachineName.ToLower()+'_ip') -ResourceGroupName $resourceGroupName -Location $location -AllocationMethod Dynamic
$vnet = Get-AzVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroupName
$VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $nic.Id
New-AzVM -VM $VirtualMachine -ResourceGroupName $resourceGroupName -Location $location
Hope this post would save you some time and helped you fixing your issue.
Hello. I need some help please. It doesnt work for me
ReplyDeleteDiyarbakır
ReplyDeleteKırklareli
Kastamonu
Siirt
Diyarbakır
7EWE2
görüntülüshow
ReplyDeleteücretli show
HOJUU
24E42
ReplyDeleteErzincan Lojistik
Kırşehir Lojistik
Samsun Evden Eve Nakliyat
Samsun Parça Eşya Taşıma
Edirne Evden Eve Nakliyat
4F01B
ReplyDeleteÇankırı Lojistik
Çorum Lojistik
Bursa Lojistik
Antep Lojistik
Yozgat Parça Eşya Taşıma
1656C
ReplyDeleteEryaman Parke Ustası
Hatay Lojistik
Karabük Parça Eşya Taşıma
Bitlis Evden Eve Nakliyat
Referans Kimliği Nedir
Eskişehir Lojistik
Tunceli Parça Eşya Taşıma
Aksaray Parça Eşya Taşıma
Isparta Evden Eve Nakliyat
22546
ReplyDeleteMersin Lojistik
Ünye Mutfak Dolabı
Aksaray Şehirler Arası Nakliyat
Çerkezköy Asma Tavan
Trabzon Lojistik
Ağrı Evden Eve Nakliyat
Iğdır Evden Eve Nakliyat
Giresun Lojistik
Sakarya Şehir İçi Nakliyat
مكافحة الحشرات بالاحساء dNRiE3fLLP
ReplyDeleteشركة مكافحة الصراصير بالدمام sNuz8qjAaY
ReplyDeleteE09B4D9400
ReplyDeletetiktok türk takipçi