I am trying to integrate the use of Shared Image Galleries into what was a working capture process using Packer in Azure DevOps for a WVD Image. Previously a segment of this code created a gold VM and captured into a normal Resource Group for use. Now id like to copy it to a Shared Image Gallery aswell
Having worked through a few examples I believe I am there or there-about with the code however when I execute this in a pipeline I get the following error:
Template validation failed. Errors are shown below.
Errors validating build âazure-armâ. 1 error(s) occurred:
- unknown configuration key: âshared_image_gallery_destinationâ
##[error]Packer validate command failed. This could happen if task does not support packer version.
Finishing: Build Canary image v20h2
I have tried to simplify out my JSON and have less variables etc but it does not seem to matter. I have tried Packer version 1.7.0 and dropped down multiple versions to no avail.
I have included my JSON minus a couple of bits below as there is not really anything data pertinent other than variable calls.
Would appreciate any assistance but it just does not seem the like the Shared Image Gallery destination parameter but the website article suggests this is right for capturing the image and copying it to the SIG.
Code Start
{
âvariablesâ: {
âclient_idâ: ââ,
âclient_secretâ: ââ,
âAppInstallStorageAccountNameâ: ââ,
âAppInstallStorageAccountKeyâ: ââ,
"az_tenant_id": "{{env `az_tenant_id`}}",
"subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
"wvd_goldimage_rg": "{{env `wvd_goldimage_rg`}}",
"SharedImageGalleryRG": "{{env `wvd_SharedGallery_rg`}}",
"SharedGalleryName": "{{env `wvd_SharedGalleryName`}}",
"SharedImageVersion": "{{env `wvd_SharedImageVersion`}}",
"wvdmanaged_image_name": "{{env `wvd_ManagedImageName`}}",
"packaged_app_installs_path": "{{env `packaged_app_installs_path`}}",
"Build_DefinitionName": "{{env `Build_DefinitionName`}}",
"Build_BuildNumber": "{{env `Build_BuildNumber`}}",
"Release_Branch": "{{env `Release_Branch`}}",
"Redstone_Release": "20H2"
},
âbuildersâ: [
{
âtypeâ: âazure-armâ,
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"tenant_id": "{{user `az_tenant_id`}}",
"subscription_id": "{{user `subscription_id`}}",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsDesktop",
"image_offer": "Windows-10",
"image_sku": "20h2-evd",
"location": "UK South",
"vm_size": "Standard_B2S",
"communicator": "winrm",
"winrm_use_ssl": "true",
"winrm_insecure": "true",
"winrm_timeout": "3m",
"winrm_username": "packer",
"shared_image_gallery_destination": {
"resource_group": "{{user `SharedImageGalleryRG`}}",
"gallery_name": "{{user `SharedGalleryName`}}",
"image_name": "{{user `wvdmanaged_image_name`}}-Build{{user `Build_BuildNumber`}}",
"image_version": "{{user `SharedImageVersion`}}",
"replication_regions": "northeurope"
},
"managed_image_name": "{{user `wvdmanaged_image_name`}}-Build{{user `Build_BuildNumber`}}",
"managed_image_resource_group_name": "{{user `wvd_goldimage_rg`}}",
"temp_resource_group_name": "###",
"virtual_network_name": "###",
"virtual_network_subnet_name": "###",
"private_virtual_network_with_public_ip": "True",
"virtual_network_resource_group_name": "###",
"azure_tags": {
"Project": "aodevwvd"
},
"async_resourcegroup_delete":true
}
],
âprovisionersâ: [
{
âtypeâ: âpowershellâ,
âinlineâ: [
â$ErrorActionPreference=âStopââ,
"Write-Host \"Preparing to establish connection to Azure File Share\"",
"Import-Module -Name Smbshare -Force -Scope Local",
"$Usr='Azure\\'+\"{{user `AppInstallStorageAccountName`}}\"",
"Write-Host \"{{user `packaged_app_installs_path`}}\" -Username \"$Usr\" -Password \"{{user `AppInstallStorageAccountKey`}}\"",
"New-SmbMapping -LocalPath W: -RemotePath \"{{user `packaged_app_installs_path`}}\" -Username \"$Usr\" -Password \"{{user `AppInstallStorageAccountKey`}}\"",
"Write-Host \"'W:' drive has been successfully mapped, preparing for application installation\""
]
},
{
"type": "powershell",
"inline": [
" # NOTE: Entering SYSPREP Phase for Golden Image.",
"if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
"& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
"while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }",
" # NOTE: Completed SYSPREP Phase for Golden Image. Closing out...",
"Write-Host \"Completed the WVD Golden Capture Process, closing out.\""
]
}
]
}
Code End