Closed GuyPaddock closed 2 years ago
Thanks for the feedback! We are currently investigating and will update you shortly.
@GuyPaddock thanks for pointing this out. I completely agree the steps to download are not clear and or not there at all.
@Heidilohr can you take a look?
Any Update on this?
Go to the VM in the Portal and deallocate it , click on the Disk, then Disk Export, follow the instructions to create a SAS and then you can download the VHD. Might be worthwhile deploying Hyper-V in Azure to save some time in the download and resulting upload process.
Found this blog post that helps: https://www.microcloud.nl/create-a-wim-file-from-the-wvd-vhd-file/#_First,_we_need
Hello there.
any update on this - it seems that we shouldnt have to provision an VM so that we can get to the DISK and then export as an image.
Have a need for the same -- do we have any update on this? Would prefer to download a marketplace image without having to provision a VM?
Two years since issue was raised and docs are neither updated to say you cannot do this, nor updated to explain how to do it!
Tim
Here is how to download an image without provisioning a VM using Powershell:
$location = "Central US" $rgName = "rg" $region = "Central US"
$imgver = Get-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName "gallery" -GalleryImageDefinitionName "myImg" -Name "myImgVer" $galleryImageVersionID = $imgver.Id
$diskName = "tmpOSDisk" $imageOSDisk = @{Id = $galleryImageVersionID} $OSDiskConfig = New-AzDiskConfig -Location $location -CreateOption "FromImage" -GalleryImageReference $imageOSDisk $osd = New-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Disk $OSDiskConfig
$sas = Grant-AzDiskAccess -ResourceGroupName $rgName -DiskName $osd.Name -Access "Read" -DurationInSecond 3600 $wc = New-Object System.Net.WebClient $wc.DownloadFile($sas.AccessSAS, "c:\targetdir\myImg.vhd")
Revoke-AzDiskAccess -ResourceGroupName $rgName -DiskName $diskName Remove-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Force
Closing the loop on this - the change from dcbrown16 has been incorporated to provide links on how to do this.
Here is how to download an image without provisioning a VM using Powershell:
$location = "Central US" $rgName = "rg" $region = "Central US"
$imgver = Get-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName "gallery" -GalleryImageDefinitionName "myImg" -Name "myImgVer" $galleryImageVersionID = $imgver.Id
$diskName = "tmpOSDisk" $imageOSDisk = @{Id = $galleryImageVersionID} $OSDiskConfig = New-AzDiskConfig -Location $location -CreateOption "FromImage" -GalleryImageReference $imageOSDisk $osd = New-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Disk $OSDiskConfig
$sas = Grant-AzDiskAccess -ResourceGroupName $rgName -DiskName $osd.Name -Access "Read" -DurationInSecond 3600 $wc = New-Object System.Net.WebClient $wc.DownloadFile($sas.AccessSAS, "c:\targetdir\myImg.vhd")
Don't forget to delete the disk created above.
Revoke-AzDiskAccess -ResourceGroupName $rgName -DiskName $diskName Remove-AzDisk -ResourceGroupName $rgName -DiskName $diskName -Force
I did the same, but then by using the az-cli.
Hey @030 , Could you please share the template for the code which you used using az - cli ? I am having the above use case as well and If the solution was towards az-cli formatted, it would be really helpful.
@Lancelot0105 I do not work with Azure at the moment.
Hey @030, could you please help me with the flow on how I can download an image without provisioning a VM using az cli?
I used https://github.com/Azure/azure-storage-azcopy back then, but no idea if that would still work well as I do not work with Azure anymore for more than a year now.
The docs say:
And:
How do you download the image? This is not clear.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.