Packer with Azure

Yes! It's works.

First of all you need to install packer. After that – Azure plugin for Packer (you could download executable package or compile proper package with GOlang placing it to directory with packer plugins).

In my case I used *.exe files, downloaded from Github release. Also you can find packer configuration for different OS here.

Lets analyze my configuration file and run packer to azure.

 

{
  "variables": {
    "sn": "Subscription1",
    "ps": "D:/azure/Subscription-credentials.publishsettings",
    "sa": "noteits",
    "example_dir": "D:/azure/example"
  },
  "builders": [
    {
      "type": "azure",
      "publish_settings_path": "{{user `ps`}}",
      "subscription_name": "{{user `sn`}}",
      "storage_account": "{{user `sa`}}",
      "storage_account_container": "images",
      "os_type": "Windows",
      "os_image_label": "Windows Server 2012 R2 Datacenter, September 2015",
      "location": "West US",
      "instance_size": "Small",
      "user_image_label": "WS2012R2DC"
    }
  ],
  "provisioners": [
    {
      "type": "azure-custom-script-extension",
      "script_path": "{{user `example_dir`}}/ws2012-setup.ps1"
    }
  ]
}

So, we have Storage account named noteits. This name will be used in  "storage_account" field, as "sa" variable.

Then we need to obtain  "publish_settings_path". Just run: 

Get-AzurePublishSettingsFile

It is powershell cmdlet, you need to install Azure Powershell for proper work. 

This command will open https://manage.windowsazure.com/publishsettings/index?client=powershell in browser and downloads file with subscription information.

Also configure OS Type and other settings, such as location, instant type, provision scripts and options, etc. 

When everything is ready just run commend:

packer.exe build -only=azure ws2012az.json

Voila!

packerazure