packer-cn/builder/azure/arm
Chris Bednarski 5b5888b230 Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
..
README.md Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
artifact.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
azure_client.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
builder.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
builder_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
config.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
config_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
deployment_factory.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
deployment_factory_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
deployment_poller.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
deployment_poller_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
openssh_key_pair.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
openssh_key_pair_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_capture_image.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_capture_image_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_create_resource_group.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_create_resource_group_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_delete_os_disk.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_delete_os_disk_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_delete_resource_group.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_delete_resource_group_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_deploy_template.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_deploy_template_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_get_ip_address.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_get_ip_address_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_get_os_disk.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_get_os_disk_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_power_off_compute.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_power_off_compute_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_validate_template.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
step_validate_template_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
template.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
template_parameters.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
template_parameters_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
tempname.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00
tempname_test.go Initial import of Microsoft contributed code 2016-03-14 20:08:35 -07:00

README.md

packer-azure-arm

The ARM flavor of packer-azure utilizes the Azure Resource Manager APIs. Please see the overview for more information about ARM as well as the benefit of ARM.

Getting Started

The ARM APIs use OAUTH to authenticate, so you must create a Service Principal. The following articles are a good starting points.

There are three pieces of configuration you will need as a result of creating a Service Principal.

  1. Client ID (aka Service Principal ID)
  2. Client Secret (aka Service Principal generated key)
  3. Client Tenant (aka Azure Active Directory tenant that owns the Service Principal)

You will also need the following.

  1. Subscription ID
  2. Resource Group
  3. Storage Account

Resource Group is where your storage account is located, and Storage Account is where the created packer image will be stored.

The Service Principal has been tested with the following permissions. Please review the document for the built in roles for more details.

  • Owner

NOTE: the Owner role is too powerful, and more explicit set of roles is TBD. Issue #183 is tracking this work.

Sample Ubuntu

The following is a sample Packer template for use with the Packer Azure for ARM builder.

{
    "variables": {
        "cid": "your_client_id",
        "cst": "your_client_secret",
        "tid": "your_client_tenant",
        "sid": "your_subscription_id",

        "rgn": "your_resource_group",
        "sa": "your_storage_account"
    },
    "builders": [
        {
            "type": "azure-arm",

            "client_id": "{{user `cid`}}",
            "client_secret": "{{user `cst`}}",
            "subscription_id": "{{user `sid`}}",
            "tenant_id": "{{user `tid`}}",

            "capture_container_name": "images",
            "capture_name_prefix": "my_prefix",

            "image_publisher": "Canonical",
            "image_offer": "UbuntuServer",
            "image_sku": "14.04.3-LTS",

            "location": "South Central US",

            "resource_group_name": "{{user `rgn`}}",
            "storage_account": "{{user `sa`}}",

            "vm_size": "Standard_A1"
        }
    ],
    "provisioners": [
        {
            "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
            "inline": [
                "sudo apt-get update",
            ],
            "inline_shebang": "/bin/sh -x",
            "type": "shell"
        }
    ]
}

Using the above template, Packer would be invoked as follows.

NOTE: the following variables must be changed based on your subscription. These values are just dummy values, but they match format of expected, e.g. if the value is a GUID the sample is a GUID.

packer build^
  -var cid="593c4dc4-9cd7-49af-9fe0-1ea5055ac1e4"^
  -var cst="GbzJfsfrVkqL/TLfZY8TXA=="^
  -var sid="ce323e74-56fc-4bd6-aa18-83b6dc262748"^
  -var tid="da3847b4-8e69-40bd-a2c2-41da6982c5e2"^
  -var rgn="My Resource Group"^
  -var sa="mystorageaccount"^
  c:\packer\ubuntu_14_LTS.json

Please see the config_sameples/arm directory for more examples of usage.