Unable to create packer VM via azure arm with os disk type Standard HDD

Hi, I am using packer with azure-arm template to build up managed images and store them in Share Image Gallery or Azure Compute Gallery.

While creating the temporary vm resource, I am getting below error. Below error is related to OS Disk type which is by default picking Premium SSD type while that has been disallowed by our team so it’s failing like below.

==> azure-arm: Validating deployment template …
==> azure-arm: → ResourceGroupName : ‘packer-rg-bo’
==> azure-arm: → DeploymentName : ‘pkrdpu4fs7gzjif’
==> azure-arm: Deploying deployment template …
==> azure-arm: → ResourceGroupName : ‘packer-rg-bo’
==> azure-arm: → DeploymentName : ‘pkrdpu4fs7gzjif’
==> azure-arm: Code=“DeploymentFailed” Message=“At least one resource deployment operation failed. Please list deployment operations for details. Please see Deployment history - Azure Resource Manager | Microsoft Learn for usage details.” Details=[{“code”:“Conflict”,“message”:“{\r\n "status": "Failed",\r\n "error": {\r\n "code": "ResourceDeploymentFailure",\r\n "message": "The resource operation completed with terminal provisioning state ‘Failed’.",\r\n "details": [\r\n {\r\n "code": "RequestDisallowedByPolicy",\r\n "message": "Resource ‘pkrosu4fs7gzjif’ was disallowed by policy. Reasons: ‘INFORMATION : THE USE OF PREMIUM SSD IS DENIED. PLEASE ENSURE THAT ON DISKS TAB EITHER STANDARD HDD OR STANDARD SSD IS SELECTED OR DEPLOYMENT MAY FAIL.\nPLEASE READ DEP DOCUMENTATION FOR MORE INFORMATION’. See error details for policy resource IDs. Target: ‘/subscriptions/xxxxxxxxxxxx/resourceGroups/packer-rg-bo/providers/Microsoft.Compute/disks/pkrosu4fs7gzjif’."\r\n }\r\n ]\r\n }\r\n}”}]
==> azure-arm:
==> azure-arm: Deleting individual resources …
==> azure-arm: Could not retrieve OS Image details: unable to obtain a OS disk for “slazpckrbo01”, please check that the instance has been created

Kindly suggest us any option parameter to using in builders section or packer-nft.json to choose Standard HDD as OS Disk type.

Thanks and Regards
Rahul Negi

You could try ‘managed_image_storage_account_type’ but might be just the captured image (since default seems to be ‘Standard_LRS’). Description is a bit unclear to me.

Edit: Not your description, but on the website :slight_smile:

Hi, I have already tried ‘managed_image_storage_account_type’ option but that didn’t worked for me.

Actually the first step when Packer tries to create a temporary VM resource then it selects OS Disk type as Premium SSD by default. So, I want this option to be Standard_HDD, basically I’m looking out for a parameter which I can add/pass in my config “builders” section of my “packer-nft.json” file such that it creates a temporary Packer VM with basic disk type.

Please let me know if still something is unclear. I’ll try to explain more.

For reference when creating a VM on Azure then once we proceed ahead with Disks then it provides a drop down menu with OS disk type as “Standard HDD, Standard SSD, Premium SSD” and you will notice that Azure by default creates Premium SSD disk type VM but we can choose Standard HDD there manually. Similarly, I want such behavior in Packer configuration.

Please suggest. Thanks

Please check the configuration of packer-nft.json file as below

"builders": [
  {
      "type": "azure-arm",
      "use_azure_cli_auth": "True",
      "os_type": "Linux",
      "os_disk_size_gb": "64",

      "shared_image_gallery": {
        "subscription": "{{user `subscription_id`}}",
        "resource_group": "{{user `sig_gallery_resource_group`}}",
        "gallery_name": "{{user `sig_gallery_name`}}",
        "image_name": "{{user `sig_image_name`}}",
        "image_version": "{{user `sig_source_image_version`}}"
      },

      "shared_image_gallery_destination": {
        "subscription": "{{user `subscription_id`}}",
        "resource_group": "{{user `sig_gallery_resource_group`}}",
        "gallery_name": "{{user `sig_gallery_name`}}",
        "image_name": "{{user `sig_image_name`}}",
        "image_version": "{{user `sig_dest_image_version`}}",
        "replication_regions": ["{{user `location`}}"]
      },

      "temp_resource_group_name": "{{user `temp_resource_group_name`}}",
      "temp_compute_name": "{{user `temp_compute_name`}}",
      "private_virtual_network_with_public_ip": true,
      "polling_duration_timeout": "0h30m0s",

      "ssh_username": "{{user `ssh_username`}}",
      "ssh_private_key_file": "{{user `ssh_private_key_file`}}",
      "ssh_pty": "true",

      "location": "{{user `location`}}",
      "vm_size": "{{user `vm_size`}}",
      "managed_image_name": "{{user `managed_image_name`}}",
      "managed_image_storage_account_type": "Standard_LRS",
      "disk_caching_type": "None",
      "managed_image_resource_group_name": "{{user `sig_gallery_resource_group`}}",

      
      "shared_image_gallery_timeout": "2h5m2s",
              
      "azure_tags": {
        "packer": "true"
      }
    
    }
],

Is there any chance to avoid this error and make the temporary VM with standard OS disk type always instead of primary. I don’t know why it is trying to create VM with OS disk type Primary SSD.

Kindly suggest.

I’m having similar issue where a policy is blocking my image deployments due to a restriction in using premium disk