Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you download images from Azure Image Gallery? #32886

Closed
GuyPaddock opened this issue Jun 6, 2019 — with docs.microsoft.com · 15 comments
Closed

How do you download images from Azure Image Gallery? #32886

GuyPaddock opened this issue Jun 6, 2019 — with docs.microsoft.com · 15 comments

Comments

Copy link

GuyPaddock commented Jun 6, 2019

The docs say:

The second option is to create the image locally by downloading the image, provisioning a Hyper-V VM, and customizing it to suit your needs, which we cover in the following section.

And:

Once you've downloaded the image to a local location, open Hyper-V Manager to create a VM with the VHD you copied.

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.

@mimckitt
Copy link
Contributor

mimckitt commented Jun 6, 2019

Thanks for the feedback! We are currently investigating and will update you shortly.

@mimckitt
Copy link
Contributor

mimckitt commented Jun 7, 2019

@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?

Copy link

TETZUO commented Jun 28, 2019

Any Update on this?

Copy link
Contributor

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.

@PRMerger17 PRMerger17 added the Pri2 label Sep 5, 2019
Copy link

@lmcdasm
Copy link

lmcdasm commented Jan 13, 2021

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.

@LH-MSFT
Copy link

LH-MSFT commented Jun 29, 2021

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?

@tim-ebu
Copy link

tim-ebu commented Oct 10, 2021

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

@Mslance
Copy link

Mslance commented May 2, 2022

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

@dknappettmsft
Copy link
Contributor

Closing the loop on this - the change from dcbrown16 has been incorporated to provide links on how to do this.

#please-close

@030
Copy link

030 commented Jun 10, 2022

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.

@Lancelot0105
Copy link

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.

@030
Copy link

030 commented Jan 4, 2024

@Lancelot0105 I do not work with Azure at the moment.

@Lancelot0105
Copy link

Hey @030, could you please help me with the flow on how I can download an image without provisioning a VM using az cli?

@030
Copy link

030 commented Jan 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests