azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Save-AzureRmVMImage

Open wbrophy opened this issue 10 years ago • 1 comments

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.

wbrophy avatar May 27 '16 18:05 wbrophy

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

wbrophy avatar May 27 '16 23:05 wbrophy