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.

az image create -- Limited command options as compared to Azure Portal

See original GitHub issue

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug

Perhaps a maturity issue as opposed to bug. The documentation for az image create does not list a clear way to specify storage-sku for each data disk attached to an image.

Also encryption options visible in Image create UI, is not listed in configuration options in Azure CLI.

Sample command: – this is a long multi-line command in windows cmd. It works, but does not allow specifying encryption at rest, or per data disk storage type, as seen in the GUI.

az image create --name image1 -g resource_group01 --os-type Linux --location eastus --hyper-v-generation V1 ^ –zone-resilient true --storage-sku Premium_LRS ^ –source https://storage1.blob.core.windows.net/container1/root-disk.vhd ^ –data-disk-sources https://storage1.blob.core.windows.net/container1/second-disk.vhd https://storagestratozen.blob.core.windows.net/container1/third-disk.vhd ^ –os-disk-caching ReadWrite ^ –data-disk-caching ReadWrite ^

//Relevant documentation https://docs.microsoft.com/en-us/cli/azure/image?view=azure-cli-latest#az-image-create

In Summary:

  1. How do I specify encryption for the image, as seen in the UI?
  2. How do I specify storage type (premium etc) per data disk if multiple?
  3. How do I specify disk read/write caching per data disk added? – I mean usually I’ll do read/write for everything, but why does the option not exist?

Is there a simple way to do this via azure cli, or do I have to use some way to input json (no example documentation). Is the only option an ARM template?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
olayemiocommented, Jul 9, 2021

@zhoxing-ms Yes, all these features are supported in the REST API. Customers are only able to specify all three settings if they use disks, snapshots or blobs to create the image. For customers that use VMs to create their image, the settings have to be applied to the disks on the VM before the image capture process.

Here is a sample that has uses encryption, specifies storage type, and the caching.

{
  "location": "East US",
  "properties": {
    "storageProfile": {
      "osDisk": {
        "osType": "Linux",
        "snapshot": {
          "id": "/subscriptions/[subid}/resourceGroups/{rg}/providers/Microsoft.Compute/disks/{osDiskName}"
        },
        "diskEncryptionSet": {
          "id": "/subscriptions/[subid}/resourceGroups/{rg}/providers/Microsoft.Compute/diskEncryptionSets/{desName}"
        },
        "caching": "None",
        "osState": "Generalized"
      },
      "dataDisks": [
        {
          "lun": 0,
          "managedDisk": {
            "id": "/subscriptions/[subid}/resourceGroups/{rg}/providers/Microsoft.Compute/disks/{diskName0}"
          },
          "diskEncryptionSet": {
            "id": "/subscriptions/[subid}/resourceGroups/{rg}/providers/Microsoft.Compute/diskEncryptionSets/{desName}"
          },
          "storageAccountType": "Premium_LRS",
          "caching": "ReadOnly"
        },
        {
          "lun": 1,
          "managedDisk": {
            "id": "/subscriptions/[subid}/resourceGroups/{rg}/providers/Microsoft.Compute/disks/{diskName1}"
          },
          "diskEncryptionSet": {
            "id": "/subscriptions/[subid}/resourceGroups/{rg}/providers/Microsoft.Compute/diskEncryptionSets/{desName}"
          },
          "storageAccountType": "Standard_LRS",
          "caching": "ReadWrite"
        }
      ],
      "zoneResilient": false
    }
  }
}
0reactions
zhoxing-mscommented, Jul 10, 2021

@olayemio OK, I see. Thank you for the example. We will arrange development for this requirement~

Read more comments on GitHub >

github_iconTop Results From Across the Web

Find Azure Marketplace image information using the Azure CLI
Learn how to use the Azure CLI to find image URNs and purchase plan parameters, like the publisher, offer, SKU, and version, for...
Read more >
az image - Microsoft Learn
Commands ; az image copy. Copy a managed image (or vm) to other regions. It requires the source disk to be available. ;...
Read more >
az vm | Microsoft Learn
Information on available virtual machine images. az vm image accept-terms. Accept Azure Marketplace term so that the image can be used to create...
Read more >
Share VM images in a compute gallery - Azure Virtual Machines
Learn how to use an Azure Compute Gallery to share VM images. ... the --replica-count argument in the az sig image-version create command....
Read more >
Troubleshoot images in an Azure Compute Gallery
Creating or modifying image definitions · Has an 80-character limit · Contains only English letters, numbers, underscores, hyphens and periods ...
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