example template that builds sysprepped Azure ARM Windows VM Image

463 views
Skip to first unread message

Rajinder Singh

unread,
Nov 5, 2016, 5:00:31 PM11/5/16
to Packer
I have been using AWS EBS Windows AMI with packers for a long time.
I am trying to build a Azure Windows VM and running into issues.
If I don't sysprep the VM everything works well. I can use ARM template and provision windows VM from it.
However I need to provison VM scalesets. They require sysprepped image.

So I added a new provisoner at the end of building the image.

    {
      "type": "windows-shell",
      "pause_before": "10s",
     "scripts": [
        "{{user `scripts_dir`}}/sysprep.bat"
      ]
    }


 It runs sysprep.bat file which looks like this.
%windir%\system32\sysprep\sysprep.exe /generalize /oobe /shutdown

Image was built successfully with no errors

However when I provision the VM scaleset the deployment never finishes. It just hangs.
If I replace my custom image with a stock windows server 2012 R2 image VMSS provisions

So I am looking for a simple example of building a sysprepped windows vm for Azure.

Many thanks for your help in advance. 

Alvaro Miranda Aguilera

unread,
Nov 6, 2016, 7:17:49 AM11/6/16
to packe...@googlegroups.com

On Sat, Nov 5, 2016 at 10:00 PM, Rajinder Singh <rejo...@gmail.com> wrote:
%windir%\system32\sysprep\sysprep.exe /generalize /oobe /shutdown

Hello.


What It may be happening is the VM is not being created properly.

If that command returns to the promp,. then packer will think the VM failed since he cant connect and shutdown.

What about if you replace the shutdown command with that:
"%windir%\system32\sysprep\sysprep.exe /generalize /oobe /shutdown"

I would replace %windir% with the actual folder name just to be sure.

Hope this helps.
Alvaro.


--
Alvaro

Rajinder Singh

unread,
Nov 6, 2016, 9:09:57 AM11/6/16
to Packer
I finally found out what the issue was.

I had to add /quiet to my sysprep command.

I also upgraded to packer 11

Because I did not have /quiet sysprep was opening a dialog box and due to that the sysprep process was not finishing properly. There were no errors logged but when I created VM's from the image I was getting a vague "Provisioning failed..." error.

I tested created VM's and VM Scalesets with the image I created and they both work.

I like packer but I did not find many good examples for creating Windows VM's on Azure. Most were Linux.

So I am going to find time and blog them here http://www.rajinders.com

Thanks for taking the time to help me.

%windir%\system32\sysprep\sysprep.exe /generalize /oobe /shutdown /quiet

ja...@bitflight.io

unread,
Apr 18, 2017, 3:56:15 PM4/18/17
to Packer
Hi,
Did you manage to write any blogs on this?
I am also having a very hard time finding any details on packer with Azure-arm.
Any time i attempt to run any kind of powershell script i just get an error.

Did you get past this?

Rajinder Singh

unread,
Apr 19, 2017, 5:52:39 PM4/19/17
to Packer
Reply all
Reply to author
Forward
0 new messages