Azure-Samples / Azure-Samples/managed-disks-powershell-getting-started
i'm also trying to launch a vm using existing managed os disk, my script is not working.
- Dominant language
- PowerShell
- Stars
- 29
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
#Provide the name of your resource group
$resourceGroupName ='Demopractice'
#Provide the size of the virtual machine
$virtualMachineSize = 'Standard_DS3'
#Provide the name of the virtual machine
$virtualMachineName = 'demoserver1'
#Provide the name of an existing virtual network where virtual machine will be created
$virtualNetworkName = 'Demopractice-vnet'
#provide location where your os disk located
$loc='centralus'
#Provide the name of the Managed Disk...................
$managedDiskName='server1_OsDisk_1_256262bb5eec498bb8f574dfd9a4cd57'
#Get managed disk ID
$managedDiskId=Get-AzureRmDisk -ResourceGroupName Demopractice -DiskName 'server1_OsDisk_1_256262bb5eec498bb8f574dfd9a4cd57'
$AvailabilitySet = Get-AzureRmAvailabilitySet -ResourceGroupName $resourceGroupName -Name "demo"
$nic=Get-AzureRmNetworkInterface -ResourceGroupName $resourceGroupName -Name "server1351"
$nsg = Get-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroupName -Name "server1-nsg"
$nic.NetworkSecurityGroup = $nsg
$nic | Set-AzureRmNetworkInterface
#Initialize virtual machine configuration
$VirtualMachine = New-AzureRmVMConfig -VMName $virtualMachineName -VMSize $virtualMachineSize -AvailabilitySetId $AvailabilitySet.Id
#Add a network interface to a new virtual machine
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $nic.Id
$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name $managedDiskId.Name -ManagedDiskId $managedDiskId.Id -CreateOption Attach -Windows -Caching ReadWrite -DiskSizeInGB $managedDiskId.DiskSizeGB
New-AzureRmVM -ResouceGroupName $resourceGroupName -Location $loc -VM $VirtualMachine.StorageProfile.OsDisk
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the PowerShell script with the supplied resource group, managed disk, network interface, and availability set values, then inspect the final New-AzureRmVM invocation and its error output. Done means a new VM launches successfully using the existing managed OS disk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100