Hi,
We are facing “Waiting for WinRM to become available” error while creating a windows machine. telnet for port “5985” is working. And below is our packer script:
{
“builders”: [
{
“type”: “azure-arm”,
"subscription_id": "{{user `subscription_id`}}",
"client_id": "{{user `client_id`}}",
"client_secret": "{{user `client_secret`}}",
"tenant_id": "{{user `tenant_id`}}",
"managed_image_resource_group_name": "myPackerGroup",
"managed_image_name": "Windowsimage-{{timestamp}}",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2016-Datacenter",
"communicator": "winrm",
"winrm_username": "packer",
"winrm_use_ssl": false,
"winrm_insecure": true,
"winrm_timeout": "2m",
"virtual_network_name": "myPackerGroup-vnet",
"virtual_network_subnet_name": "default",
"build_resource_group_name": "myPackerGroup",
"azure_tags": {
"XXXX": "yes",
"dept": "XXXX",
"task": "Image deployment"
},
"vm_size": "Standard_D2_v3"
}
],
"provisioners": [{
"type": "powershell",
"inline": [
"Add-WindowsFeature Web-Server",
"& $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 } }"
]
}]
}
Please suggest any solution ASAP.