Winrm timeout when running packer script through azure cloud shell

RETRO 0 Reputation points
2023-04-10T10:45:51.0966667+00:00

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",
      "client_id":"a4171f6a-993a-4759-995b-cee9d3b1c83b",
      "client_secret":"rJW8Q~X3zhDx7QH0Q0FMIRCp~4-nUAmM0Pfv0dfN",
      "tenant_id":"43c8605a-15cd-4d10-b213-31a5373d3999",
      "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,585 questions
{count} votes