4

I used my existing VNET, Resource group, Subnet to be used by packer for creating a VM and take an image from it. I have taken the Windows image from the market place. The packer launches a Vm but times out while connecting to it. I have included my JSON file below { "builders": [{ "type": "azure-arm",

"client_id": "XXXXXX",
"client_secret": "XXXXXX",
"tenant_id": "XXXXXX",
"subscription_id": "XXXXXX",

"managed_image_resource_group_name": "test",
"managed_image_name": "myPackerImage",

"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2016-Datacenter",

"communicator": "winrm",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_timeout": "3m",
"winrm_password": "Welcome@123456",
"winrm_username": "packer",

"azure_tags": {
"dept": "Engineering",
"task": "Image deployment"
},
"build_resource_group_name" : "test",
"virtual_network_name": "test",
"virtual_network_resource_group_name" : "test",
"virtual_network_subnet_name" : "test",
"vm_size": "Standard_DS2_v2"
}],
"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 } }"
]
 }]
}

I have used the existing resource group, VNET and subnet. But it times out while connecting to the VM. It shows the following error azure-arm output will be in this color.

==> azure-arm: Running builder ...
==> azure-arm: Getting tokens using client secret
azure-arm: Creating Azure Resource Manager (ARM) client ...
==> azure-arm: Using existing resource group ...
==> azure-arm: -> ResourceGroupName : 'test'
==> azure-arm: -> Location : 'uksouth'
==> azure-arm: Validating deployment template ...
==> azure-arm: -> ResourceGroupName : 'test'
==> azure-arm: -> DeploymentName : 'pkrdpn19ib1zopk'
==> azure-arm: Deploying deployment template ...
==> azure-arm: -> ResourceGroupName : 'test'
==> azure-arm: -> DeploymentName : 'kvpkrdpn19ib1zopk'
==> azure-arm: Getting the certificate's URL ...
==> azure-arm: -> Key Vault Name : 'pkrkvn19ib1zopk'
==> azure-arm: -> Key Vault Secret Name : 'packerKeyVaultSecret'
==> azure-arm: -> Certificate URL : 'https://pkrkvn19ib1zopk.vault.azure.net/secrets/packerKeyVaultSecret/37221457a5a3459fa0da7f3745e1c9ee'
==> azure-arm: Setting the certificate's URL ...
==> azure-arm: Validating deployment template ...
==> azure-arm: -> ResourceGroupName : 'test'
==> azure-arm: -> DeploymentName : 'pkrdpn19ib1zopk'
==> azure-arm: Deploying deployment template ...
==> azure-arm: -> ResourceGroupName : 'test'
==> azure-arm: -> DeploymentName : 'pkrdpn19ib1zopk'
==> azure-arm: Getting the VM's IP address ...
==> azure-arm: -> ResourceGroupName : 'test'
==> azure-arm: -> PublicIPAddressName : 'pkripn19ib1zopk'
==> azure-arm: -> NicName : 'pkrnin19ib1zopk'
==> azure-arm: -> Network Connection : 'PrivateEndpoint'
==> azure-arm: -> IP Address : '10.1.0.5'
==> azure-arm: Waiting for WinRM to become available...
==> azure-arm: Timeout waiting for WinRM.
==> azure-arm:
==> azure-arm: The resource group was not created by Packer, deleting individual resources ...
==> azure-arm: -> Deployment: pkrdpn19ib1zopk
==> azure-arm: -> Microsoft.Compute/virtualMachines : 'pkrvmn19ib1zopk'
==> azure-arm: -> Microsoft.Network/networkInterfaces : 'pkrnin19ib1zopk'
==> azure-arm: -> Microsoft.Compute/disks : '/subscriptions/2b87c584-986d-4a3c-9e56-012df416db72/resourceGroups/test/providers/Microsoft.Compute/disks/pkrosn19ib1zopk'
==> azure-arm:
==> azure-arm: The resource group was not created by Packer, deleting individual resources ...
==> azure-arm: Could not retrieve OS Image details
==> azure-arm: -> Deployment: kvpkrdpn19ib1zopk
==> azure-arm: -> Microsoft.KeyVault/vaults/secrets : 'pkrkvn19ib1zopk/packerKeyVaultSecret'
==> azure-arm: -> Microsoft.KeyVault/vaults : 'pkrkvn19ib1zopk'
==> azure-arm: -> : ''
==> azure-arm: Error deleting resource. Please delete manually.
==> azure-arm:
==> azure-arm: Name:
==> azure-arm: Error: Unable to parse path of image
==> azure-arm:
==> azure-arm: The resource group was not created by Packer, not deleting ...
Build 'azure-arm' errored: Timeout waiting for WinRM.

==> Some builds didn't complete successfully and had errors:
--> azure-arm: Timeout waiting for WinRM.

==> Builds finished but no artifacts were created.
MoonHorse
  • 1,966
  • 2
  • 24
  • 46
Anbu Kugan
  • 61
  • 1
  • 5

2 Answers2

1

Try using a VM Size that does not contain an 'S', such as changing from Standard_DS2_v2 to Standard_D2_v2 etc. These were the setting used during testing:

"communicator": "winrm",
"winrm_username": "packer",
"winrm_insecure": true,
"winrm_use_ssl": true,
"vm_size": "Standard_D2_v2"

I had the same issue with a Windows-10 image and the solution worked for me!

This is a known case by Packer and it is still open. Please check this thread for further information and solutions: https://github.com/hashicorp/packer/issues/8658#issuecomment-600857201

MoonHorse
  • 1,966
  • 2
  • 24
  • 46
0

azure-arm buffer is full. You'll need to wait a little while before trying again.