github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/builder/azure/arm/README.md (about)

     1  # packer-azure-arm
     2  
     3  The ARM flavor of packer-azure utilizes the
     4  [Azure Resource Manager APIs](https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx).
     5  Please see the
     6  [overview](https://azure.microsoft.com/en-us/documentation/articles/resource-group-overview/)
     7  for more information about ARM as well as the benefit of ARM.
     8  
     9  ## Getting Started
    10  
    11  The ARM APIs use OAUTH to authenticate, so you must create a Service
    12  Principal.  The following articles are a good starting points.
    13  
    14   * [Automating Azure on your CI server using a Service Principal](http://blog.davidebbo.com/2014/12/azure-service-principal.html)
    15   * [Authenticating a service principal with Azure Resource Manager](https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/)
    16  
    17  There are three pieces of configuration you will need as a result of
    18  creating a Service Principal.
    19  
    20   1. Client ID (aka Service Principal ID)
    21   1. Client Secret (aka Service Principal generated key)
    22   1. Client Tenant (aka Azure Active Directory tenant that owns the
    23      Service Principal)
    24  
    25  You will also need the following.
    26  
    27   1. Subscription ID
    28   1. Resource Group
    29   1. Storage Account
    30  
    31  Resource Group is where your storage account is located, and Storage
    32  Account is where the created packer image will be stored.
    33  
    34  The Service Principal has been tested with the following [permissions](https://azure.microsoft.com/en-us/documentation/articles/role-based-access-control-configure/).
    35  Please review the document for the [built in roles](https://azure.microsoft.com/en-gb/documentation/articles/role-based-access-built-in-roles/)
    36  for more details.
    37  
    38   * Owner
    39  
    40  > NOTE: the Owner role is too powerful, and more explicit set of roles
    41  > is TBD.  Issue #183 is tracking this work.
    42  
    43  ### Sample Ubuntu
    44  
    45  The following is a sample Packer template for use with the Packer
    46  Azure for ARM builder.
    47  
    48  ```json
    49  {
    50      "variables": {
    51          "cid": "your_client_id",
    52          "cst": "your_client_secret",
    53          "tid": "your_client_tenant",
    54          "sid": "your_subscription_id",
    55  
    56          "rgn": "your_resource_group",
    57          "sa": "your_storage_account"
    58      },
    59      "builders": [
    60          {
    61              "type": "azure-arm",
    62  
    63              "client_id": "{{user `cid`}}",
    64              "client_secret": "{{user `cst`}}",
    65              "subscription_id": "{{user `sid`}}",
    66              "tenant_id": "{{user `tid`}}",
    67  
    68              "capture_container_name": "images",
    69              "capture_name_prefix": "my_prefix",
    70  
    71              "image_publisher": "Canonical",
    72              "image_offer": "UbuntuServer",
    73              "image_sku": "14.04.3-LTS",
    74  
    75              "location": "South Central US",
    76  
    77              "resource_group_name": "{{user `rgn`}}",
    78              "storage_account": "{{user `sa`}}",
    79  
    80              "vm_size": "Standard_A1"
    81          }
    82      ],
    83      "provisioners": [
    84          {
    85              "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    86              "inline": [
    87                  "sudo apt-get update",
    88              ],
    89              "inline_shebang": "/bin/sh -x",
    90              "type": "shell"
    91          }
    92      ]
    93  }
    94  ```
    95  
    96  Using the above template, Packer would be invoked as follows.
    97  
    98  > NOTE: the following variables must be **changed** based on your
    99  > subscription.  These values are just dummy values, but they match
   100  > format of expected, e.g. if the value is a GUID the sample is a
   101  > GUID.
   102  
   103  ```bat
   104  packer build^
   105    -var cid="593c4dc4-9cd7-49af-9fe0-1ea5055ac1e4"^
   106    -var cst="GbzJfsfrVkqL/TLfZY8TXA=="^
   107    -var sid="ce323e74-56fc-4bd6-aa18-83b6dc262748"^
   108    -var tid="da3847b4-8e69-40bd-a2c2-41da6982c5e2"^
   109    -var rgn="My Resource Group"^
   110    -var sa="mystorageaccount"^
   111    c:\packer\ubuntu_14_LTS.json
   112  ```
   113  
   114  Please see the
   115  [config_sameples/arm](https://github.com/Azure/packer-azure/tree/master/config_examples)
   116  directory for more examples of usage.