Creating VHD Azure blob SAS URL from Azure Managed Image

  1. Create Azure Shared Image Gallery image version from the managed image
  2. Create Azure Managed Disk from the Shared Image Gallery (SIG) image version we created
  3. Generate temporary SAS URL to the Azure Managed Disk
  4. Use AzCopy to copy the SAS URL of the managed disk to our own Azure storage account container as a VHD
  5. Generate SAS from the VHD in our storage account

Create Azure Shared Image Gallery from Managed Image

# Create resource group
az group create --name avsig1000 --location eastus
# Create shared image gallery resource
az sig create --resource-group avsig1000 --gallery-name gallery1000
# Create shared image gallery image definition
az sig image-definition create --resource-group avsig1000 --gallery-name gallery1000 --gallery-image-definition image1000 --os-type Linux --publisher mypublisher1000 --offer myoffer1000 --sku mysku1000
# Create shared image gallery image version from existing managed image
az sig image-version create --resource-group avsig1000 --gallery-name gallery1000 --gallery-image-definition image1000 --gallery-image-version 1.0.0 --target-regions eastus=1=standard_lrs --managed-image /subscriptions/MY_SUBSCRIPTION_ID/resourceGroups/MY_RESOURCE_GROUP_WITH_MANAGED_IMAGE/providers/Microsoft.Compute/images/MY_MANAGED_IMAGE_NAME
/subscriptions/MY_SUBSCRIPTION_ID/resourceGroups/avsig1000/providers/Microsoft.Compute/galleries/gallery1000/images/image1000/versions/1.0.0

Create Azure Managed Disk from Shared Image Gallery

az disk create --resource-group avsig1000 --location eastus --name my-disk-from-image --gallery-image-reference /subscriptions/MY_SUBSCRIPTION_ID/resourceGroups/avsig1000/providers/Microsoft.Compute/galleries/gallery1000/images/image1000/versions/1.0.0

Generate SAS URL for the Managed Disk

az disk grant-access --resource-group avsig1000 --name my-disk-from-image --duration-in-seconds 36000 --access-level Read
https://md-3r0d4kzc5jhz.blob.core.windows.net/s3vffgdlczdj/abcd?sv=2017-04-17&sr=b&si=e931bb4b-8a79-4119-b4bb-8b2c1b763369&sig=SIGNATURE_WILL_BE_HERE

AzCopy Managed Disk to Our Azure Blob Storage Container

# Create storage account
az storage account create --resource-group avsig1000 --name avvhdstorage1000 --location eastus --sku Standard_LRS --kind StorageV2 --access-tier Hot
# Create storage container
az storage container create --resource-group avsig1000 --account-name avvhdstorage1000 --name myvhds
az storage container generate-sas --account-name avvhdstorage1000 --name myvhds --permissions acw --expiry "2020-08-08T00:00:00Z"
azcopy copy "https://md-3r0d4kzc5jhz.blob.core.windows.net/s3vffgdlczdj/abcd?sv=2017-04-17&sr=b&si=e931bb4b-8a79-4119-b4bb-8b2c1b763369&sig=SIGNATURE_WILL_BE_HERE" "https://avvhdstorage1000.blob.core.windows.net/myvhds/myimage1.vhd?se=2020-08-08T00%3A00%3A00Z&sp=acw&sv=2018-11-09&sr=c&sig=SIGNATURE_WILL_BE_HERE" --blob-type PageBlob

Generate SAS for VHD in our Storage Account

az storage container generate-sas --account-name avvhdstorage1000 --name myvhds --permissions rl --start "2020-08-04T00:00:00Z" --expiry "2020-09-08T00:00:00Z"
https://avvhdstorage1000.blob.core.windows.net/myvhds/myimage1.vhd?st=2020–08–04T00%3A00%3A00Z&se=2020–09–08T00%3A00%3A00Z&sp=rl&sv=2018–11–09&sr=c&sig=SIGNATURE_HERE

My other posts and videos about Azure VM offers

--

--

--

Principal Engineer / Architect, FastTrack for Azure at Microsoft

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CI for Open Source Dotnet

Self-serve data pipelining platform

What is “FLOATING POINT ROUNDING ERROR” ⁉️😲

Complete and easy-to-follow guide to make your own cool portfolio website using Django.

I Almost Uninstalled The Coding Plugin That Saves Me Hours Of Time

Azure Resource Lock — Simple 2 Steps

👨🏼‍💻Google Tag Manager : Click & Form Triggers

Introduction to HMS ML Kit — Landmark Recognition

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arsen Vladimirskiy

Arsen Vladimirskiy

Principal Engineer / Architect, FastTrack for Azure at Microsoft

More from Medium

How to Build and Deploy a Language Translation Web App using Azure Cognitive Service and Azure App…

Assigning Azure built-in roles vs Azure AD built-in roles with Azure CLI

Azure Resource group:

Build 22 — Hybrid Announcements