Save-AzureRmVMImage
Save-AzureRmVMImage https://msdn.microsoft.com/en-us/library/mt619423.aspx
Documentation identifies an Output property containing a json template. However, this does not seem to be the case: Here is what is returned from "Save-AzureRmVMImage":
RequestId IsSuccessStatusCode StatusCode ReasonPhrase
True OK OK
No Output object. (...which contains the URL(s) of the saved VHDs.) The json file ends up in the destination container, which I'm uncertain to be any help to me in a Runbook.
the following works:
write-output "Imaging $VMName" $JSONRESULT = [System.IO.Path]::GetTempFileName() $VMImage = Save-AzureRmVMImage -DestinationContainerName "images" -Name $VMName -ResourceGroupName $rg.ResourceGroupName -VHDNamePrefix $vhdPrefix -Path $JSONRESULT $result = Get-Content -Path $JSONRESULT | ConvertFrom-Json $OSDiskURI = $result.resources.properties.storageProfile.osDisk.image.uri $OSDiskURI