github.com/inloco/packer@v1.3.2/examples/azure/windows_custom_image.json (about) 1 { 2 "variables": { 3 "client_id": "{{env `ARM_CLIENT_ID`}}", 4 "client_secret": "{{env `ARM_CLIENT_SECRET`}}", 5 "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", 6 "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", 7 "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", 8 "object_id": "{{env `ARM_OJBECT_ID`}}" 9 }, 10 "builders": [ 11 { 12 "type": "azure-arm", 13 14 "client_id": "{{user `client_id`}}", 15 "client_secret": "{{user `client_secret`}}", 16 "resource_group_name": "{{user `resource_group`}}", 17 "storage_account": "{{user `storage_account`}}", 18 "subscription_id": "{{user `subscription_id`}}", 19 "object_id": "{{user `object_id`}}", 20 21 "capture_container_name": "images", 22 "capture_name_prefix": "packer", 23 24 "os_type": "Windows", 25 "image_url": "https://my-storage-account.blob.core.windows.net/path/to/your/custom/image.vhd", 26 27 "azure_tags": { 28 "dept": "engineering", 29 "task": "image deployment" 30 }, 31 32 "location": "West US", 33 "vm_size": "Standard_DS2_v2" 34 } 35 ], 36 "provisioners": [{ 37 "type": "powershell", 38 "inline": [ 39 "if( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}", 40 "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit", 41 "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 } }" 42 ] 43 }] 44 }