Winrm timeout when running packer script through azure cloud shell

RETRO 0 Reputation points

Im trying to run my packer script to create a managed image using my base image from azure marketplace but in getting winrm timeout the script that im using is as follows

  "builders": [
      "image_publisher": "MicrosoftWindowsDesktop",
      "image_offer": "Windows-11",
      "image_sku": "win11-22h2-avd",
      "communicator": "winrm",
      "managed_image_name": "{{user `managed_image_name`}}",
      "managed_image_resource_group_name": "{{user `managed_image_rg`}}",
      "os_disk_size_gb": 128,
      "os_type": "Windows",
      "subscription_id": "66118adc-b709-4533-a6be-252b2f04211e",
      "location": "eastus",
      "type": "azure-arm",
      "virtual_network_name": "{{user `vnet_name`}}",
      "virtual_network_subnet_name": "Test",
      "virtual_network_resource_group_name": "Test_Image",
      "vm_size": "Standard_DS2_v2",
      "winrm_timeout": "10m",
      "winrm_username": "Myusername@10",
      "winrm_password": "Mypassword@10",
      "winrm_port": "5985",
      "winrm_use_ssl": false,
      "winrm_insecure": true   
  "variables": {
    "managed_image_name": "my-test-image",
    "managed_image_rg": "Test_Image",
    "vnet_name": "Test_Vnet"
  "provisioners": [
      "type": "windows-restart"
      "type": "powershell",
      "inline": [
        "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force",
        "Enable-PSRemoting -Force",
        "winrm quickconfig -q",
        "winrm set winrm/config/winrs '@{MaxMemoryPerShellMB=\"512\"}'",
        "winrm set winrm/config '@{MaxTimeoutms=\"1800000\"}'",
        "winrm set winrm/config/service '@{AllowUnencrypted=\"true\"}'",
        "winrm set winrm/config/service/auth '@{Basic=\"true\"}'",
        "winrm set winrm/config/client/auth '@{Basic=\"true\"}'",
        "net stop winrm",
        "sc.exe config winrm start=auto",
        "net start winrm"

the standard should be IAC so cant make any change through portal

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,285 questions
{count} votes