More specifically, for people that were deploying using unmanaged VHD, there doesn't seem to be any documentation anywhere that mentions to use the Set-AzureRmVmSourceImage like the following example:
$vmConfig = Set-AzureRmVMSourceImage -vm $vmConfig -id $sourceimage.Id
$vmConfig = Set-AzureRmVMOSDisk -vm $vmConfig -Name $diskName -StorageAccountType Standard_LRS -DiskSizeInGB 128 -CreateOption FromImage -Linux
Previously, you could specify the Id (Uri) directly in the Set-AzureRmVmOsDisk cmdlet but this doesn't work with a managed image.
Old example:
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@Philippe-Morin
Thanks for the feedback! We are currently investigating and will update you shortly.
@Philippe-Morin I think what you are looking for might be this topic: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sa-copy-generalized which is for creating an "old" non-managed image and then creating a VM from that image. If you aren't looking at using an image, you could also try this topic: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sa-upload-generalized. Or, if you don't have a generalized VHD, you can use the "attach" method for a specialized VM: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sa-create-vm-specialized. All three of those topics should cover non-managed disks.
Thanks @cynthn!
@Philippe-Morin I will close this for now. If you feel you need more information just let us know and we can reopen and continue.
No. This describes how to deploy a VM using an unmanaged image (VHD).
I’m taking about exactly what you linked, but for a managed image created using this procedure:
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource
But then the next step “Use generalized image” only talks about the New-AzureRmVm cmdlet using simplified parameters which is super limited.
I’ve also submitted a change to the examples of the following document where I basically take example 3 and rewrite it using managed disk:
Got it.
@cynthn how would you like to proceed with this one?
fyi, this is the MS blog where I finally found the answer to what I'm suggesting. See the "Syntax Difference: Managed vs. Non-Managed" section.
@Philippe-Morin I guess I'm still kind of confused about what you are trying to do and how. I think your initial concern was about unmanaged disks using marketplace platform images: "...for people that were deploying using unmanaged VHD, there doesn't seem to be any documentation anywhere that mentions to use the Set-AzureRmVmSourceImage".
I think what you are asking for now is creating a VM using a platform image and the full-parameter set?
Except, when I look at what you are referring to in the Cmdlet reference: "Example 3: Sets properties on a virtual machine from specialized user image" that is for a user created specialized image (which means non-generalized)... which again, isn't a platform image from the marketplace.
I suspect you are wanting to use a marketplace image and managed disks, while using the full parameter set for New-AzureRmVM - is that correct? If that is the case, I am pretty sure you are right - we no longer have a doc for creating a VM using the full parameter set and specifying a platform image. Is there a reason why you want to use the full parameter set?
Thanks!
I'm sorry, I was indeed not very clear.. doing too many things at once. Let me make it hopefully clearer! Sorry for the much longer post...
For the example in https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/set-azurermvmosdisk?view=azurermps-6.4.0, I meant #2 (Sets properties on a virtual machine from generalized user image) and not #3. Sorry!
Also, now that I read my original post again, I really did a poor job at explaining. Here's what I really wanted to say:
Before, when deploying a user custom image (generalized VHD hosted on a storage account), you would create a new VM config variable using the New-AzureRmVMConfig cmdlet. You would then set all your configs, one of them being the Set-AzureRmVMOSDisk cmdlet. One of the parameter for that cmdlet was -SourceImageUri which you would point to your generalized VHD uri and you'd use the -CreateOption FromImage along with it.
Now, with managed disks, using the -SourceImageUri doesn't work to point to your source generalized managed disk. I tried using the -ManagedDiskId but that was not working either. What I found was working is to create an image using New-AzureRmImage (following https://docs.microsoft.com/en-us/azure/virtual-machines/windows/capture-image-resource).
The only documentation I could find to create a VM from that image in Microsoft docs was https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-generalized-managed which only gives the very limited New-AzureRmVm cmdlet using simplified parameters. It doesn't give an example of New-AzureRmVm using the more powerful New-AzureRmVMConfig VM config variable.
Which is what the MS blog I finally found showed that to use the New-AzureRmVMConfig to create a managed disk VM from that image, you need to leverage the Set-AzureRmVMSourceImage specifying the id of the image.
So I guess all that to say that I was really looking to have this added to the documentation page https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-generalized-managed as well as the page that talks about the Set-AzureRmVmOsDisk https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/set-azurermvmosdisk?view=azurermps-6.4.0.
On a side note, I just noticed that when using the Set-AzureRmVMSourceImage, you don't actually need to use the Set-AzureRmVmOsDisk or Add-AzureRmVMDataDisk, they will automatically get added even though the disk names are going to be random... so maybe only the page https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-generalized-managed should get the example.
Cool! Yep, the https://docs.microsoft.com/en-us/azure/virtual-machines/windows/create-vm-generalized-managed topic used to have the full syntax before the simplified parameter set was released. I think I can just pull that version out of the Git history and add it to the doc as the "using a config" or "using the extended parameters" section of the doc.
It will take me a little while before I can circle back around to updating that doc. I'm going to create a work item to track it on my side.
I'll have them close this issue. If you think of anything else, feel free to reopen the issue :)
Thanks! #please-close
No sounds good, thanks for the great follow up! And sorry for the early confusion! :)
Please provide doc of " Set-AzureRmVMSourceImage" when working in this cases.
2 months passed no follow up
@ericcwk thanks for the feedback! Sorry that I haven't had the time to add back in the full parameter set version of this content. There is a script available that has all the pieces. You can find it here: https://docs.microsoft.com/en-us/azure/virtual-machines/scripts/virtual-machines-windows-powershell-upload-generalized-script
I'd like to second (now third) the request for the standard-parameter example (can now be replaced with Set-AzVMSourceImage for the newer Az module) to be added to the main document. The above comment finally solved by problem, but having it buried down here at the end of a hidden comment thread is no good and lost us some hours of productivity.
I'll 15th the request....its absurd that Microsoft is pushing using managed disks and managed images EVERYWHERE (including in the AZ-103 certification exam), but the documentation STILL only shows how to use a custom managed image with the New-AzVM, OVER 1 year after this was supposedly "Closed".
New-AzVM to create VMs is bollocks for any decent programmer who wants full control without a single cmdlet that has frigging 100 parameters (exaggeration of course, but point made, same as what the other posters have said).
There should also be a re-factoring here, its only been over 2 years.
Set-AzVMSourceImage should pretty much be JUST for platform image specification
Set-AzVMOsDisk should be refactored to add a -Image or -ImageId parameter that can be used instead of -SouceImageUri.....this is pretty obvious stuff, surprised that its not been done as of Azure Powershell 2.5
Most helpful comment
fyi, this is the MS blog where I finally found the answer to what I'm suggesting. See the "Syntax Difference: Managed vs. Non-Managed" section.
https://blogs.msdn.microsoft.com/igorpag/2017/03/14/azure-managed-disks-deep-dive-lessons-learned-and-benefits/