question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Please enable VM disk export via the az CLI

See original GitHub issue

Is your feature request related to a problem? Please describe. I want to automate the image generation process, in order to include it in a CI pipeline. The only link which is missing for a fully automated process, is VM disk export - basically, the process which is described here. I found no way to do it via the az CLI, nor via a simple REST API.

Describe the solution you’d like Ideally, I would be able to do the following via the az CLI:

  1. Set a duration for OS image export for a deallocated VM.
  2. Get the SAS URL for this image.
  3. Cancel the export once the download is done, to be able to delete the VM.

Describe alternatives you’ve considered It would also be okay if there was a REST API way to perform the steps above.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
blochlcommented, Aug 25, 2021

Sorry, I have found a way to do it.

For future reference:

  1. Get the OSDisk name:
    az disk list |
        jq -r '.[] | select(.diskState == "Reserved") | .name' |
        grep "<VM name>_OsDisk_1"
    
    • Several names may appear. If unsure, to find the correct one go to the web UI (Virtual Machines[VM name]DisksOS Disk) and check the correct name.
  2. Get the export URL:
    az disk grant-access --duration-in-seconds <number of seconds to export> \
        -g "<resource group>" -n "<OSDisk name>" |
        jq -r '.accessSas'
    
  3. Download the image.
  4. Revoke access, to enable VM / disk deletion:
    az disk revoke-access -g "<resource group>" -n "<OSDisk name>"
    

Closing this issue.

1reaction
blochlcommented, Aug 24, 2021

@zhoxing-ms ,

After the code development is basically completed, we can provide you with private packages for testing in advance through edge build.

Thanks very much, I’d like that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

az disk - Microsoft Learn
Customers can set on Managed Disks or Snapshots to control the export policy on the disk. accepted values: Disabled, Enabled. --secure-vm-disk-encryption-set.
Read more >
Allow Azure CLI to attach multiple disks to a VM at once #15765
When attaching multiple disks to an Azure VM at once using the --ids parameter on az vm disk attach only one disk gets...
Read more >
Amazon EC2 FAQs - Amazon Web Services
Q: What can I do with Amazon EC2? Just as Amazon Simple Storage Service (Amazon S3) enables storage in the cloud, Amazon EC2...
Read more >
Azure Provider: Authenticating via a Service Principal and a ...
If you're using the China, German or Government Azure Clouds - you'll need to first configure the Azure CLI to work with that...
Read more >
Azure CLI list Disk - Stack Overflow
And if you want to create a snapshot from the VM, you can create it from the disks one by one through the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found