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

Creating an Image from an Azure Compute Gallery specialized image does not work #307

Closed
cloudvant opened this issue Jun 14, 2023 · 2 comments · Fixed by #308
Closed

Creating an Image from an Azure Compute Gallery specialized image does not work #307

cloudvant opened this issue Jun 14, 2023 · 2 comments · Fixed by #308
Assignees

Comments

@cloudvant
Copy link

cloudvant commented Jun 14, 2023

Overview of the Issue

I created a Citrix Cloud specialized image, with the 1.4.3 feature like this:

shared_image_gallery_replica_count = 5 #replicas per version
shared_image_gallery_timeout = "60m"
shared_gallery_image_version_exclude_from_latest = false

  shared_image_gallery_destination {
    subscription         = var.subscription_id
    resource_group       = "rg"
    gallery_name         = "images_sig"
    image_name           = "win001" #image definition
    image_version        = "23.6.14455"
    storage_account_type = "Standard_LRS"
    replication_regions  = ["eastus", "westus2"]
    specialized          = true
  }

Reproduction Steps

Then I try to create a new Image from the newly created image like this:

shared_image_gallery {
   subscription       = var.subscription_id
   resource_group = "rg"
   gallery_name     = "images_sig"
   image_name      = "win001"
   image_version   = "23.6.14455"
 }

 shared_image_gallery_destination {
   subscription             = var.subscription_id
   resource_group       = "rg"
   gallery_name           = "mages_sig"
   image_name           = "win001" #image definition
   image_version        = "23.6.14456"
   storage_account_type = "Standard_LRS"
   replication_regions  = ["eastus", "westus2"]
   specialized             = true
 }

}

This error pops up when launching the VM:

Build 'azure-arm.ppazwin001' errored after 7 minutes 3 seconds: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details." Details=[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"InvalidParameter\",\r\n \"message\": \"Parameter 'osProfile' is not allowed.\",\r\n \"target\": \"osProfile\"\r\n }\r\n}"}]

From Azure's troubleshooting page:
ERROR: Parameter 'osProfile' is not allowed

CAUSE: Admin username, password, or SSH keys were provided for a VM that was created from a specialized image version

SOLUTION: Don't include the admin username, password, or SSH keys if you intend to create a VM from that image. Otherwise, use a generalized image version and supply the admin username, password, or SSH keys

From the CLI, I am able to create a VM:

az vm create\
   --resource-group myRG  \
   --name 'myVM' \
   --image "/subscriptions/001/resourceGroups/rg/providers/Microsoft.Compute/galleries/images_sig/images/win001/versions/23.6.14455" \
   --specialized --admin-password ExampleWithMagic1!

Plugin and Packer version

Packer v1.8.7
Azure RM v1.4.3

Operating system and Environment details

MacOS Ventura 13.4

Log Fragments and crash.log files

2023/06/14 11:41:51 ui: �[1;32m==> azure-arm.ppazwin001: Deploying deployment template ...�[0m
2023/06/14 11:41:51 ui: �[1;32m==> azure-arm.ppazwin001:  -> ResourceGroupName : 'pkr-Resource-Group-uojx3vuyiv'�[0m
2023/06/14 11:41:51 ui: �[1;32m==> azure-arm.ppazwin001:  -> DeploymentName    : 'pkrdpuojx3vuyiv'�[0m
2023/06/14 11:41:51 packer-plugin-azure_v1.4.3_x5.0_darwin_amd64 plugin: 2023/06/14 11:41:51 Azure request method="PUT" request="https://management.azure.com/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourcegroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv?api-version=2018-02-01" body="{\"properties\":{\"template\":{\"$schema\":\"http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json\",\"contentVersion\":\"1.0.0.0\",\"parameters\":{\"adminPassword\":{\"type\":\"securestring\"},\"adminUsername\":{\"type\":\"string\"},\"commandToExecute\":{\"type\":\"string\"},\"dataDiskName\":{\"type\":\"string\"},\"dnsNameForPublicIP\":{\"type\":\"string\"},\"nicName\":{\"type\":\"string\"},\"nsgName\":{\"type\":\"string\"},\"osDiskName\":{\"type\":\"string\"},\"publicIPAddressName\":{\"type\":\"string\"},\"storageAccountBlobEndpoint\":{\"type\":\"string\"},\"subnetName\":{\"type\":\"string\"},\"virtualNetworkName\":{\"type\":\"string\"},\"vmName\":{\"type\":\"string\"},\"vmSize\":{\"type\":\"string\"}},\"resources\":[{\"apiVersion\":\"[variables('publicIPAddressApiVersion')]\",\"location\":\"[variables('location')]\",\"name\":\"[parameters('publicIPAddressName')]\",\"properties\":{\"dnsSettings\":{\"domainNameLabel\":\"[parameters('dnsNameForPublicIP')]\"},\"publicIPAllocationMethod\":\"[variables('publicIPAddressType')]\"},\"tags\":{\"ApplicationID\":\"PP001\",\"ApplicationName\":\"Virtual Desktop Infrastructure\",\"BusinessApplicationNumber\":\"PP001\",\"EnvironmentName\":\"Dev\"},\"type\":\"Microsoft.Network/publicIPAddresses\"},{\"apiVersion\":\"[variables('networkInterfacesApiVersion')]\",\"dependsOn\":[\"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]\"],\"location\":\"[variables('location')]\",\"name\":\"[parameters('nicName')]\",\"properties\":{\"ipConfigurations\":[{\"name\":\"ipconfig\",\"properties\":{\"privateIPAllocationMethod\":\"Dynamic\",\"publicIPAddress\":{\"id\":\"[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddressName'))]\"},\"subnet\":{\"id\":\"[variables('subnetRef')]\"}}}]},\"tags\":{\"ApplicationID\":\"PP001\",\"ApplicationName\":\"Virtual Desktop Infrastructure\",\"BusinessApplicationNumber\":\"PP001\",\"EnvironmentName\":\"Dev\"},\"type\":\"Microsoft.Network/networkInterfaces\"},{\"apiVersion\":\"[variables('apiVersion')]\",\"dependsOn\":[\"[concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]\"],\"location\":\"[variables('location')]\",\"name\":\"[parameters('vmName')]\",\"properties\":{\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":false}},\"hardwareProfile\":{\"vmSize\":\"[parameters('vmSize')]\"},\"networkProfile\":{\"networkInterfaces\":[{\"id\":\"[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]\"}]},\"osProfile\":{\"adminPassword\":\"[parameters('adminPassword')]\",\"adminUsername\":\"[parameters('adminUsername')]\",\"computerName\":\"[parameters('vmName')]\",\"secrets\":[{\"sourceVault\":{\"id\":\"[resourceId(resourceGroup().name, 'Microsoft.KeyVault/vaults', 'pkrkvuojx3vuyiv')]\"},\"vaultCertificates\":[{\"certificateStore\":\"My\",\"certificateUrl\":\"https://pkrkvuojx3vuyiv.vault.azure.net/secrets/packerKeyVaultSecret/06e6ec4ef7ce4b5189451523eafbf3ff\"}]}],\"windowsConfiguration\":{\"provisionVMAgent\":true,\"winRM\":{\"listeners\":[{\"certificateUrl\":\"https://pkrkvuojx3vuyiv.vault.azure.net/secrets/packerKeyVaultSecret/06e6ec4ef7ce4b5189451523eafbf3ff\",\"protocol\":\"https\"}]}}},\"storageProfile\":{\"imageReference\":{\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/paypal_rg/providers/Microsoft.Compute/galleries/paypal_images_sig/images/ppazwin001/versions/23.6.14455\"},\"osDisk\":{\"caching\":\"ReadWrite\",\"createOption\":\"FromImage\",\"name\":\"[parameters('osDiskName')]\",\"osType\":\"Windows\"}}},\"tags\":{\"ApplicationID\":\"PP001\",\"ApplicationName\":\"Virtual Desktop Infrastructure\",\"BusinessApplicationNumber\":\"PP001\",\"EnvironmentName\":\"Dev\"},\"type\":\"Microsoft.Compute/virtualMachines\"},{\"apiVersion\":\"2022-08-01\",\"condition\":\"[not(empty(parameters('commandToExecute')))]\",\"dependsOn\":[\"[resourceId('Microsoft.Compute/virtualMachines/', parameters('vmName'))]\"],\"location\":\"[variables('location')]\",\"name\":\"[concat(parameters('vmName'), '/extension-customscript')]\",\"properties\":{\"autoUpgradeMinorVersion\":true,\"publisher\":\"Microsoft.Compute\",\"settings\":{\"commandToExecute\":\"[parameters('commandToExecute')]\"},\"type\":\"CustomScriptExtension\",\"typeHandlerVersion\":\"1.8\"},\"tags\":{\"ApplicationID\":\"PP001\",\"ApplicationName\":\"Virtual Desktop Infrastructure\",\"BusinessApplicationNumber\":\"PP001\",\"EnvironmentName\":\"Dev\"},\"type\":\"Microsoft.Compute/virtualMachines/extensions\"}],\"variables\":{\"addressPrefix\":\"10.0.0.0/16\",\"apiVersion\":\"2018-06-01\",\"location\":\"[resourceGroup().location]\",\"managedDiskApiVersion\":\"2017-03-30\",\"networkInterfacesApiVersion\":\"2017-04-01\",\"networkSecurityGroupsApiVersion\":\"2019-04-01\",\"publicIPAddressApiVersion\":\"2017-04-01\",\"publicIPAddressType\":\"Dynamic\",\"sshKeyPath\":\"[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]\",\"subnetAddressPrefix\":\"10.0.0.0/24\",\"subnetName\":\"default\",\"subnetRef\":\"[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]\",\"virtualNetworkName\":\"packer-vnet\",\"virtualNetworkResourceGroup\":\"access_RG\",\"virtualNetworksApiVersion\":\"2017-04-01\",\"vmStorageAccountContainerName\":\"images\",\"vnetID\":\"[resourceId(variables('virtualNetworkResourceGroup'), 'Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]\"}},\"parameters\":{\"adminPassword\":{\"value\":\"SPz3a5OzS1Sjk3a9TZURFKMxwQvINha7\"},\"adminUsername\":{\"value\":\"packer\"},\"commandToExecute\":{\"value\":\"\"},\"dataDiskName\":{\"value\":\"pkrdduojx3vuyiv\"},\"dnsNameForPublicIP\":{\"value\":\"pkrvmuojx3vuyiv\"},\"nicName\":{\"value\":\"pkrniuojx3vuyiv\"},\"nsgName\":{\"value\":\"pkrsguojx3vuyiv\"},\"osDiskName\":{\"value\":\"pkrosuojx3vuyiv\"},\"publicIPAddressName\":{\"value\":\"pkripuojx3vuyiv\"},\"storageAccountBlobEndpoint\":{\"value\":\"\"},\"subnetName\":{\"value\":\"pkrsnuojx3vuyiv\"},\"virtualNetworkName\":{\"value\":\"pkrvnuojx3vuyiv\"},\"vmName\":{\"value\":\"pkrvmuojx3vuyiv\"},\"vmSize\":{\"value\":\"Standard_D4s_v4\"}},\"mode\":\"Incremental\"}}"
2023/06/14 11:41:52 packer-plugin-azure_v1.4.3_x5.0_darwin_amd64 plugin: 2023/06/14 11:41:52 Azure response status="201 Created" method="PUT" request="https://management.azure.com/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourcegroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv?api-version=2018-02-01" x-ms-request-id="f8baef03-9b9d-4c94-9b2d-bef842fc6caa" body="{\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv\",\"name\":\"pkrdpuojx3vuyiv\",\"properties\":{\"templateHash\":\"15584466449492202313\",\"parameters\":{\"adminPassword\":{\"type\":\"SecureString\"},\"adminUsername\":{\"type\":\"String\",\"value\":\"packer\"},\"commandToExecute\":{\"type\":\"String\",\"value\":\"\"},\"dataDiskName\":{\"type\":\"String\",\"value\":\"pkrdduojx3vuyiv\"},\"dnsNameForPublicIP\":{\"type\":\"String\",\"value\":\"pkrvmuojx3vuyiv\"},\"nicName\":{\"type\":\"String\",\"value\":\"pkrniuojx3vuyiv\"},\"nsgName\":{\"type\":\"String\",\"value\":\"pkrsguojx3vuyiv\"},\"osDiskName\":{\"type\":\"String\",\"value\":\"pkrosuojx3vuyiv\"},\"publicIPAddressName\":{\"type\":\"String\",\"value\":\"pkripuojx3vuyiv\"},\"storageAccountBlobEndpoint\":{\"type\":\"String\",\"value\":\"\"},\"subnetName\":{\"type\":\"String\",\"value\":\"pkrsnuojx3vuyiv\"},\"virtualNetworkName\":{\"type\":\"String\",\"value\":\"pkrvnuojx3vuyiv\"},\"vmName\":{\"type\":\"String\",\"value\":\"pkrvmuojx3vuyiv\"},\"vmSize\":{\"type\":\"String\",\"value\":\"Standard_D4s_v4\"}},\"mode\":\"Incremental\",\"provisioningState\":\"Accepted\",\"timestamp\":\"2023-06-14T15:41:52.7629896Z\",\"duration\":\"PT0.0007207S\",\"correlationId\":\"f8baef03-9b9d-4c94-9b2d-bef842fc6caa\",\"providers\":[{\"namespace\":\"Microsoft.Network\",\"resourceTypes\":[{\"resourceType\":\"publicIPAddresses\",\"locations\":[\"eastus\"]},{\"resourceType\":\"networkInterfaces\",\"locations\":[\"eastus\"]}]},{\"namespace\":\"Microsoft.Compute\",\"resourceTypes\":[{\"resourceType\":\"virtualMachines\",\"locations\":[\"eastus\"]}]}],\"dependencies\":[{\"dependsOn\":[{\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Network/publicIPAddresses/pkripuojx3vuyiv\",\"resourceType\":\"Microsoft.Network/publicIPAddresses\",\"resourceName\":\"pkripuojx3vuyiv\"}],\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Network/networkInterfaces/pkrniuojx3vuyiv\",\"resourceType\":\"Microsoft.Network/networkInterfaces\",\"resourceName\":\"pkrniuojx3vuyiv\"},{\"dependsOn\":[{\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Network/networkInterfaces/pkrniuojx3vuyiv\",\"resourceType\":\"Microsoft.Network/networkInterfaces\",\"resourceName\":\"pkrniuojx3vuyiv\"}],\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Compute/virtualMachines/pkrvmuojx3vuyiv\",\"resourceType\":\"Microsoft.Compute/virtualMachines\",\"resourceName\":\"pkrvmuojx3vuyiv\"},{\"dependsOn\":[{\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Compute/virtualMachines/pkrvmuojx3vuyiv\",\"resourceType\":\"Microsoft.Compute/virtualMachines\",\"resourceName\":\"pkrvmuojx3vuyiv\"}],\"id\":\"/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourceGroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Compute/virtualMachines/pkrvmuojx3vuyiv/extensions/extension-customscript\",\"resourceType\":\"Microsoft.Compute/virtualMachines/extensions\",\"resourceName\":\"pkrvmuojx3vuyiv/extension-customscript\"}]}}"
2023/06/14 11:41:52 packer-plugin-azure_v1.4.3_x5.0_darwin_amd64 plugin: 2023/06/14 11:41:52 Azure request method="GET" request="https://management.azure.com/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourcegroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv/operationStatuses/08585148495729958001?api-version=2018-02-01" body=""
2023/06/14 11:41:52 packer-plugin-azure_v1.4.3_x5.0_darwin_amd64 plugin: 2023/06/14 11:41:52 Azure response status="200 OK" method="GET" request="https://management.azure.com/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourcegroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv/operationStatuses/08585148495729958001?api-version=2018-02-01" x-ms-request-id="9311557f-3843-4af2-bc03-c19c158318b0" body="{\"status\":\"Running\"}"
2023/06/14 11:42:22 packer-plugin-azure_v1.4.3_x5.0_darwin_amd64 plugin: 2023/06/14 11:42:22 Azure request body="" method="GET" request="https://management.azure.com/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourcegroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv/operationStatuses/08585148495729958001?api-version=2018-02-01"
2023/06/14 11:42:22 packer-plugin-azure_v1.4.3_x5.0_darwin_amd64 plugin: 2023/06/14 11:42:22 Azure response x-ms-request-id="f89deeac-d601-4177-8034-dc98c12f6dcf" body="{\"status\":\"Failed\",\"error\":{\"code\":\"DeploymentFailed\",\"message\":\"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\"details\":[{\"code\":\"BadRequest\",\"message\":\"{\\r\\n  \\\"error\\\": {\\r\\n    \\\"code\\\": \\\"InvalidParameter\\\",\\r\\n    \\\"message\\\": \\\"Parameter 'osProfile' is not allowed.\\\",\\r\\n    \\\"target\\\": \\\"osProfile\\\"\\r\\n  }\\r\\n}\"}]}}" status="200 OK" method="GET" request="https://management.azure.com/subscriptions/9131afd8-4fbe-4b48-9680-723502256f82/resourcegroups/pkr-Resource-Group-uojx3vuyiv/providers/Microsoft.Resources/deployments/pkrdpuojx3vuyiv/operationStatuses/08585148495729958001?api-version=2018-02-01"
2023/06/14 11:42:22 ui: �[1;32m==> azure-arm.ppazwin001: ERROR: -> DeploymentFailed : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.
==> azure-arm.ppazwin001: ERROR:   -> BadRequest
==> azure-arm.ppazwin001: ERROR:   -> InvalidParameter : Parameter 'osProfile' is not allowed.
==> azure-arm.ppazwin001:�[0m
2023/06/14 11:42:22 ui error: �[1;31m==> azure-arm.ppazwin001: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details." Details=[{"code":"BadRequest","message":"{\r\n  \"error\": {\r\n    \"code\": \"InvalidParameter\",\r\n    \"message\": \"Parameter 'osProfile' is not allowed.\",\r\n    \"target\": \"osProfile\"\r\n  }\r\n}"}]�[0m
2023/06/14 11:42:22 ui: �[1;32m==> azure-arm.ppazwin001: 
==> azure-arm.ppazwin001: Deleting Virtual Machine deployment and its attatched resources...�[0m

@github-actions
Copy link

This issue has been synced to JIRA for planning.
JIRA ID: HPR-1221

@JenGoldstrich
Copy link
Contributor

Hey @cloudvant I have released v1.4.4 of the plugin which fixes this, thanks for reporting it!

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