Packer: Azure - Temp Resource Group - Failure to Create Image

Created on 8 Feb 2018  ยท  23Comments  ยท  Source: hashicorp/packer

Environment

RHEL 7.3
Packer 1.1.3
Azure

JSON File

{
  "variables": {
    "client_id": "{{env `ARM_CLIENT_ID`}}",
    "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
    "resource_group": "{{env `ARM_RESOURCE_GROUP`}}",
    "temp_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
    "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
    "ssh_user": "XXXXX",
    "ssh_pass": "XXXXXXXXX"
  },
  "builders": [{
    "type": "azure-arm",

    "client_id": "{{user `client_id`}}",
    "client_secret": "{{user `client_secret`}}",
    "subscription_id": "{{user `subscription_id`}}",

    "os_type": "Linux",
    "image_publisher": "RedHat",
    "image_offer": "RHEL",
      "image_sku": "7.3",
      "image_version": "latest",
      "ssh_pty": "true",

    "managed_image_resource_group_name": "{{user `resource_group`}}",
    "managed_image_name": "RHEL73",

    "azure_tags": {
        "dept": "XXX",
        "task": "image deployment"
    },

    "location": "East US",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [{
    "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "yum update -y",
      "wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm",
      "yum install -y epel-release-latest-7.noarch.rpm",
      "yum update -y",
      "yum install -y python python-pip jq ansible git",
      "git clone https://github.com/ansible/ansible.git",
      "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
    ],
    "inline_shebang": "/bin/sh -x",
    "type": "shell",
    "skip_clean": true
  }]
}

Error

$ packer build managed_rhel73.json
azure-arm output will be in this color.

==> azure-arm: Running builder ...
    azure-arm: Creating Azure Resource Manager (ARM) client ...
==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:
==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
Build 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF

==> Some builds didn't complete successfully and had errors:
--> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF

==> Builds finished but no artifacts were created.

Debug output

2018/02/08 10:54:46 ui: ESC[0;32m    azure-arm: Creating Azure Resource Manager (ARM) client ...ESC[0m
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure request body="" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01"
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response x-ms-request-id="XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01"
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response x-ms-request-id="XXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01"
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure request method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" body=""
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response x-ms-request-id="XXXXX-6d90-XXXX-XXXXd-XXXXXXXXX" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}" status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview"
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" x-ms-request-id="XXXXX-6d90-XXXX-XXXXd-XXXXXXXXX" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}"
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure request method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/packer-Resource-Group-8k50wmw5nq?api-version=2016-09-01" body=""
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/packer-Resource-Group-8k50wmw5nq?api-version=2016-09-01" x-ms-request-id="df1a9c08-114f-459c-94b3-18aa5ce54d29" body="" status="403 Forbidden"
2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/packer-Resource-Group-8k50wmw5nq?api-version=2016-09-01" x-ms-request-id="df1a9c08-114f-459c-94b3-18aa5ce54d29" body="" status="403 Forbidden" method="HEAD"
2018/02/08 10:54:47 ui: ESC[1;32m==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:ESC[0m
2018/02/08 10:54:47 ui error: ESC[1;31m==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOFESC[0m
2018/02/08 10:54:47 [INFO] (telemetry) ending azure-arm
2018/02/08 10:54:47 [INFO] (telemetry) found error: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/08 10:54:47 ui error: ESC[1;31mBuild 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOFESC[0m
2018/02/08 10:54:47 Builds completed. Waiting on interrupt barrier...
2018/02/08 10:54:47 machine readable: error-count []string{"1"}
2018/02/08 10:54:47 ui error:
==> Some builds didn't complete successfully and had errors:
2018/02/08 10:54:47 machine readable: azure-arm,error []string{"resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: \"\" error: EOF"}
2018/02/08 10:54:47 ui error: --> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/08 10:54:47 ui:
==> Builds finished but no artifacts were created.
2018/02/08 10:54:47 [INFO] (telemetry) Finalizing.
2018/02/08 10:54:48 waiting for all plugin processes to complete...
2018/02/08 10:54:48 /usr/local/bin/packer: plugin process exited
2018/02/08 10:54:48 /usr/local/bin/packer: plugin process exited

I am trying to use existing resource-group for the temp resource group, because I cannot operate outside my rg. I see the following entry:

2018/02/08 10:54:47 packer: 2018/02/08 10:54:47 Azure response method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/packer-Resource-Group-8k50wmw5nq?api-version=2016-09-01" x-ms-request-id="df1a9c08-114f-459c-94b3-18aa5ce54d29" body="" status="403 Forbidden"

...which is telling me that Packer is not honoring "temp_resource_group_name" and is attempting to create temp resource group anyway, which is resulting in 403 and failing to create an image.

Any pointers?

Thanks again!!

buildeazure

Most helpful comment

@SwampDragons , you're absolutely right. If I do remove 'location' it does work. This 403 error was completely throwing me off. Thank you so much @SwampDragons and @boumenot for your help!!

All 23 comments

The error message does not match what you are trying to do. Let me walk through what I see.

  1. The error message says it cannot find the image RHEL73.
  2. You said the builder is not honoring your resource group, but you defined a variable called temp_resource_group_name not a setting. There is no setting called temp_resource_group_name.
  3. I assume you want the setting build_resource_group_name, which isn't defined anywhere in your configuration. Check the docs for usage.

Thanks for your reply @boumenot. I am sorry that I didn't include my env.variables that I source, but I actually do source them prior to attempt to build an image. Here is the edited version:

#!/bin/bash
#
echo "Unset variables..."
unset ARM_CLIENT_ID
unset ARM_SUBSCRIPTION_ID
unset ARM_TENANT_ID
unset ARM_CLIENT_SECRET
unset ARM_RESOURCE_GROUP
unset ARM_STORAGE_ACCOUNT
#
export ARM_CLIENT_ID="XXXXXXXXXXXXXXXXXXX"
export ARM_SUBSCRIPTION_ID="XXXXXXXXXXXXXXXXXXX"
export ARM_TENANT_ID="XXXXXXXXXXXXXXXXXXX"
export ARM_CLIENT_SECRET="XXXXXXXXXXXXXXXXXXX"
export ARM_RESOURCE_GROUP="test-rg"
export ARM_STORAGE_ACCOUNT="svcstor1"
export ssh_user="XXXXXXXXXXXXXXXXXXX"
export ssh_pass="XXXXXXXXXXXXXXXXXXX"

Now, you're absolutely right, I should have put in build_resource_group_name instead of temp_resource_group_name, which I did, albeit it is still failing:

2018/02/09 07:53:11 ui:     azure-arm: Creating Azure Resource Manager (ARM) client ...
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure request method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" body=""
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" x-ms-request-id="23052afe-947d-4baa-96d9-c6e90118f3a4" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}"
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" x-ms-request-id="23052afe-947d-4baa-96d9-c6e90118f3a4" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" status="200 OK"
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure request method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" body=""
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" x-ms-request-id="2b4e5c68-aac0-470e-b9a4-95c8d2f2c672" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}"
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response x-ms-request-id="2b4e5c68-aac0-470e-b9a4-95c8d2f2c672" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}" status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview"
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure request method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/packer-Resource-Group-7hpfrs6n4t?api-version=2016-09-01" body=""
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response status="403 Forbidden" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/packer-Resource-Group-7hpfrs6n4t?api-version=2016-09-01" x-ms-request-id="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX" body=""
2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/packer-Resource-Group-7hpfrs6n4t?api-version=2016-09-01" x-ms-request-id="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX" body="" status="403 Forbidden" method="HEAD"
2018/02/09 07:53:11 ui: ==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:
2018/02/09 07:53:11 ui error: ==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/09 07:53:11 [INFO] (telemetry) ending azure-arm
2018/02/09 07:53:11 [INFO] (telemetry) found error: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/09 07:53:11 ui error: Build 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/09 07:53:11 Builds completed. Waiting on interrupt barrier...
2018/02/09 07:53:11 machine readable: error-count []string{"1"}
2018/02/09 07:53:11 ui error:
==> Some builds didn't complete successfully and had errors:
2018/02/09 07:53:11 machine readable: azure-arm,error []string{"resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: \"\" error: EOF"}

It is complaining at RHEL73 not being found because the image itself does not exist.

2018/02/09 07:53:11 ui: ==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.

I am building the image RHEL73 using packer off the offered image_offer from Azure (line 20 in build JSON file)

What makes me thing that Packer is not honoring a build resource group is the following string:

2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure request method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX/resourcegroups/packer-Resource-Group-7hpfrs6n4t?api-version=2016-09-01" body=""

As you see above, there is an attempt to create a Packer resource group packer-Resource-Group-7hpfrs6n4t .

It looks like it is attempting to create a resource group to build an image and right after, on the following line gets 403:

2018/02/09 07:53:11 packer: 2018/02/09 07:53:11 Azure response status="403 Forbidden" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourcegroups/packer-Resource-Group-7hpfrs6n4t?api-version=2016-09-01" x-ms-request-id="7XXXXXXXXXXXXXXXXXXXXXXX" body=""

Yet again, thank you for your feedback and help!

Please re-post your new configuration. My guess is you still forgot to move build_resource_group_name from variables to the builder section of the configuration.

Thanks for looking into it @boumenot. Here are the files:

File: env

#!/bin/bash
#
echo "Unset variables..."
unset ARM_CLIENT_ID
unset ARM_SUBSCRIPTION_ID
unset ARM_TENANT_ID
unset ARM_CLIENT_SECRET
unset ARM_RESOURCE_GROUP
unset ARM_STORAGE_ACCOUNT
#
export ARM_CLIENT_ID="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_SUBSCRIPTION_ID="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_TENANT_ID="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_CLIENT_SECRET="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_RESOURCE_GROUP="test-rg"
export ARM_STORAGE_ACCOUNT="svcstor1"
export ssh_user="XXXX"
export ssh_pass="XXXXXXXXXXXXXXX"

File: managed_rhel73.json

{
  "variables": {
    "client_id": "{{env `ARM_CLIENT_ID`}}",
    "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
    "resource_group": "{{env `ARM_RESOURCE_GROUP`}}",
    "build_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
    "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
    "ssh_user": "XXXXXXX",
    "ssh_pass": "XXXXXXXXX"
  },
  "builders": [{
    "type": "azure-arm",

    "client_id": "{{user `client_id`}}",
    "client_secret": "{{user `client_secret`}}",
    "subscription_id": "{{user `subscription_id`}}",

    "os_type": "Linux",
    "image_publisher": "RedHat",
    "image_offer": "RHEL",
      "image_sku": "7.3",
      "image_version": "latest",
      "ssh_pty": "true",

    "managed_image_resource_group_name": "{{user `resource_group`}}",
    "managed_image_name": "RHEL73",

    "azure_tags": {
        "dept": "TSG",
        "task": "image deployment"
    },

    "location": "East US",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [{
    "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "yum update -y",
      "wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm",
      "yum install -y epel-release-latest-7.noarch.rpm",
      "yum update -y",
      "yum install -y python python-pip jq ansible git",
      "git clone https://github.com/ansible/ansible.git",
      "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
    ],
    "inline_shebang": "/bin/sh -x",
    "type": "shell",
    "skip_clean": true
  }]
}

You have this

{
  "variables": {
    "build_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
  },
  "builders": [{
    "type": "azure-arm",
  }],
  "provisioners": [{
     }]
}

You want this.

{
  "variables": {
  },
  "builders": [{
    "type": "azure-arm",
    "build_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
  }],
  "provisioners": [{
     }]
}

Note that build_resource_group_name is not a variable, but rather a setting.

gonna close this because it looks like we've found the issue, and it doesn't look like a bug. If you do discover that there is an issue with packer, please feel free to open a new ticket.

Thanks for your reply @boumenot . Modified my JSON file as follows:

File: managed_rhel73.json

{
  "variables": {
    "client_id": "{{env `ARM_CLIENT_ID`}}",
    "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
    "resource_group": "{{env `ARM_RESOURCE_GROUP`}}",
    "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
    "ssh_user": "centos",
    "ssh_pass": "R0b0c0p007"
  },
  "builders": [{
    "type": "azure-arm",
    "build_resource_group_name": "{{user `ARM_RESOURCE_GROUP`}}",
    "client_id": "{{user `client_id`}}",
    "client_secret": "{{user `client_secret`}}",
    "subscription_id": "{{user `subscription_id`}}",
    "os_type": "Linux",
    "image_publisher": "RedHat",
    "image_offer": "RHEL",
      "image_sku": "7.3",
      "image_version": "latest",
      "ssh_pty": "true",
    "managed_image_resource_group_name": "{{user `resource_group`}}",
    "managed_image_name": "RHEL73",
    "azure_tags": {
        "dept": "TSG",
        "task": "image deployment"
    },
    "location": "East US",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [{
    "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "yum update -y",
      "wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm",
      "yum install -y epel-release-latest-7.noarch.rpm",
      "yum update -y",
      "yum install -y python python-pip jq ansible git",
      "git clone https://github.com/ansible/ansible.git",
      "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
    ],
    "inline_shebang": "/bin/sh -x",
    "type": "shell",
    "skip_clean": true
  }]
}

File: env

#!/bin/bash
#
echo "Unset variables..."
unset ARM_CLIENT_ID
unset ARM_SUBSCRIPTION_ID
unset ARM_TENANT_ID
unset ARM_CLIENT_SECRET
unset ARM_RESOURCE_GROUP
unset ARM_STORAGE_ACCOUNT
#
export ARM_CLIENT_ID="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_SUBSCRIPTION_ID="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_TENANT_ID="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_CLIENT_SECRET="XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_RESOURCE_GROUP="test-rg"
export ARM_STORAGE_ACCOUNT="svcstor1"
export ssh_user="XXXX"
export ssh_pass="XXXXXXXXXXXXXXX"

Failed to build. Log output:

2018/02/12 07:45:23 [INFO] Packer version: 1.1.3
2018/02/12 07:45:23 Packer Target OS/Arch: darwin amd64
2018/02/12 07:45:23 Built with Go Version: go1.9.2
2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 Using internal plugin for amazon-ebsvolume
2018/02/12 07:45:23 Using internal plugin for amazon-instance
2018/02/12 07:45:23 Using internal plugin for hyperv-vmcx
2018/02/12 07:45:23 Using internal plugin for amazon-chroot
2018/02/12 07:45:23 Using internal plugin for profitbricks
2018/02/12 07:45:23 Using internal plugin for virtualbox-iso
2018/02/12 07:45:23 Using internal plugin for qemu
2018/02/12 07:45:23 Using internal plugin for amazon-ebs
2018/02/12 07:45:23 Using internal plugin for azure-arm
2018/02/12 07:45:23 Using internal plugin for cloudstack
2018/02/12 07:45:23 Using internal plugin for oneandone
2018/02/12 07:45:23 Using internal plugin for vmware-iso
2018/02/12 07:45:23 Using internal plugin for vmware-vmx
2018/02/12 07:45:23 Using internal plugin for docker
2018/02/12 07:45:23 Using internal plugin for file
2018/02/12 07:45:23 Using internal plugin for lxd
2018/02/12 07:45:23 Using internal plugin for parallels-iso
2018/02/12 07:45:23 Using internal plugin for alicloud-ecs
2018/02/12 07:45:23 Using internal plugin for googlecompute
2018/02/12 07:45:23 Using internal plugin for virtualbox-ovf
2018/02/12 07:45:23 Using internal plugin for openstack
2018/02/12 07:45:23 Using internal plugin for oracle-oci
2018/02/12 07:45:23 Using internal plugin for amazon-ebssurrogate
2018/02/12 07:45:23 Using internal plugin for lxc
2018/02/12 07:45:23 Using internal plugin for parallels-pvm
2018/02/12 07:45:23 Using internal plugin for triton
2018/02/12 07:45:23 Using internal plugin for digitalocean
2018/02/12 07:45:23 Using internal plugin for hyperv-iso
2018/02/12 07:45:23 Using internal plugin for null
2018/02/12 07:45:23 Using internal plugin for windows-shell
2018/02/12 07:45:23 Using internal plugin for ansible-local
2018/02/12 07:45:23 Using internal plugin for converge
2018/02/12 07:45:23 Using internal plugin for file
2018/02/12 07:45:23 Using internal plugin for ansible
2018/02/12 07:45:23 Using internal plugin for powershell
2018/02/12 07:45:23 Using internal plugin for puppet-masterless
2018/02/12 07:45:23 Using internal plugin for shell
2018/02/12 07:45:23 Using internal plugin for windows-restart
2018/02/12 07:45:23 Using internal plugin for chef-solo
2018/02/12 07:45:23 Using internal plugin for puppet-server
2018/02/12 07:45:23 Using internal plugin for salt-masterless
2018/02/12 07:45:23 Using internal plugin for shell-local
2018/02/12 07:45:23 Using internal plugin for chef-client
2018/02/12 07:45:23 Using internal plugin for alicloud-import
2018/02/12 07:45:23 Using internal plugin for atlas
2018/02/12 07:45:23 Using internal plugin for docker-push
2018/02/12 07:45:23 Using internal plugin for docker-save
2018/02/12 07:45:23 Using internal plugin for shell-local
2018/02/12 07:45:23 Using internal plugin for vagrant-cloud
2018/02/12 07:45:23 Using internal plugin for vsphere
2018/02/12 07:45:23 Using internal plugin for vsphere-template
2018/02/12 07:45:23 Using internal plugin for amazon-import
2018/02/12 07:45:23 Using internal plugin for compress
2018/02/12 07:45:23 Using internal plugin for docker-tag
2018/02/12 07:45:23 Using internal plugin for manifest
2018/02/12 07:45:23 Using internal plugin for vagrant
2018/02/12 07:45:23 Using internal plugin for artifice
2018/02/12 07:45:23 Using internal plugin for checksum
2018/02/12 07:45:23 Using internal plugin for docker-import
2018/02/12 07:45:23 Using internal plugin for googlecompute-export
2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 Attempting to open config file: /Users/XXXXXX/.packerconfig
2018/02/12 07:45:23 [WARN] Config file doesn't exist: /Users/XXXXXX/.packerconfig
2018/02/12 07:45:23 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[amazon-instance:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-instance alicloud-ecs:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-alicloud-ecs virtualbox-ovf:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-virtualbox-ovf googlecompute:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-googlecompute amazon-ebssurrogate:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebssurrogate digitalocean:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-digitalocean amazon-ebsvolume:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebsvolume amazon-chroot:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-chroot virtualbox-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-virtualbox-iso vmware-vmx:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-vmware-vmx file:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-file cloudstack:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-cloudstack openstack:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-openstack parallels-pvm:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-parallels-pvm lxd:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-lxd triton:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-triton profitbricks:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-profitbricks amazon-ebs:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebs oneandone:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-oneandone oracle-oci:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-oracle-oci lxc:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-lxc docker:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-docker parallels-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-parallels-iso null:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-null azure-arm:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-azure-arm hyperv-vmcx:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-hyperv-vmcx qemu:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu vmware-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-vmware-iso hyperv-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-hyperv-iso] PostProcessors:map[docker-tag:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-tag googlecompute-export:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-googlecompute-export alicloud-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-alicloud-import atlas:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-atlas docker-push:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-push docker-save:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-save vagrant:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vagrant docker-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-import artifice:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-artifice checksum:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-checksum shell-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-shell-local vsphere:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vsphere vsphere-template:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vsphere-template amazon-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-amazon-import compress:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-compress manifest:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-manifest vagrant-cloud:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vagrant-cloud] Provisioners:map[powershell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-powershell chef-solo:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-chef-solo shell-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-shell-local converge:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-converge file:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-file ansible:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-ansible shell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-shell windows-restart:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-windows-restart chef-client:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-chef-client windows-shell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-windows-shell ansible-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-ansible-local puppet-masterless:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-puppet-masterless puppet-server:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-puppet-server salt-masterless:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-salt-masterless]}
2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 Setting cache directory: /Users/XXXXXX/packer/azure/rgtest/packer_cache
2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 Loading builder: azure-arm
2018/02/12 07:45:23 Plugin could not be found. Checking same directory as executable.
2018/02/12 07:45:23 Current exe path: /usr/local/bin/packer
2018/02/12 07:45:23 Creating plugin client for path: /usr/local/bin/packer
2018/02/12 07:45:23 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-azure-arm"}
2018/02/12 07:45:23 Waiting for RPC address for: /usr/local/bin/packer
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 [INFO] Packer version: 1.1.3
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Packer Target OS/Arch: darwin amd64
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Built with Go Version: go1.9.2
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Attempting to open config file: /Users/XXXXXX/.packerconfig
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 [WARN] Config file doesn't exist: /Users/XXXXXX/.packerconfig
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[] PostProcessors:map[] Provisioners:map[]}
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Setting cache directory: /Users/XXXXXX/packer/azure/rgtest/packer_cache
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 args: []string{"packer-builder-azure-arm"}
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Plugin minimum port: 10000
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Plugin maximum port: 25000
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Plugin address: unix /var/folders/tw/w3mw4jxn1rd61llb63lc81bnblhflh/T/packer-plugin340690686
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Waiting for connection...
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Serving a plugin connection...
2018/02/12 07:45:23 Loading provisioner: shell
2018/02/12 07:45:23 Plugin could not be found. Checking same directory as executable.
2018/02/12 07:45:23 Current exe path: /usr/local/bin/packer
2018/02/12 07:45:23 Creating plugin client for path: /usr/local/bin/packer
2018/02/12 07:45:23 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2018/02/12 07:45:23 Waiting for RPC address for: /usr/local/bin/packer
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 [INFO] Packer version: 1.1.3
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Packer Target OS/Arch: darwin amd64
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Built with Go Version: go1.9.2
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Attempting to open config file: /Users/XXXXXX/.packerconfig
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 [WARN] Config file doesn't exist: /Users/XXXXXX/.packerconfig
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[] PostProcessors:map[] Provisioners:map[]}
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Setting cache directory: /Users/XXXXXX/packer/azure/rgtest/packer_cache
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 args: []string{"packer-provisioner-shell"}
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Detected home directory from env var: /Users/XXXXXX
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Plugin minimum port: 10000
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Plugin maximum port: 25000
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Plugin address: unix /var/folders/tw/w3mw4jxn1rd61llb63lc81bnblhflh/T/packer-plugin621445655
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Waiting for connection...
2018/02/12 07:45:23 packer: 2018/02/12 07:45:23 Serving a plugin connection...
2018/02/12 07:45:23 ui: azure-arm output will be in this color.
2018/02/12 07:45:23 ui:
2018/02/12 07:45:23 Build debug mode: false
2018/02/12 07:45:23 Force build: false
2018/02/12 07:45:23 On error:
2018/02/12 07:45:23 Preparing build: azure-arm
2018/02/12 07:45:23 Waiting on builds to complete...
2018/02/12 07:45:23 Starting build run: azure-arm
2018/02/12 07:45:23 Running builder: azure-arm
2018/02/12 07:45:23 [INFO] (telemetry) Starting builder azure-arm
2018/02/12 07:45:23 ui: ==> azure-arm: Running builder ...
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 :: Configuration
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ClientID=XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ClientSecret=********************************************
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ObjectID=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 TenantID=XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 SubscriptionID=XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 CaptureNamePrefix=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 CaptureContainerName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ImagePublisher=RedHat
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ImageOffer=RHEL
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ImageSku=7.3
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ImageVersion=latest
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ImageUrl=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 CustomManagedImageResourceGroupName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 CustomManagedImageName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Location=East US
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 VMSize=Standard_DS2_v2
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ManagedImageResourceGroupName=test-rg
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ManagedImageName=RHEL73
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ManagedImageStorageAccountType=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 ResourceGroupName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 StorageAccount=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 TempComputeName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 TempResourceGroupName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 BuildResourceGroupName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 CloudEnvironmentName=Public
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 VirtualNetworkName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 VirtualNetworkSubnetName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 VirtualNetworkResourceGroupName=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 CustomDataFile=
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 OSType=Linux
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 UserName=packer
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Password=********************************
2018/02/12 07:45:24 ui:     azure-arm: Creating Azure Resource Manager (ARM) client ...
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure request method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" body=""
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" x-ms-request-id="75c6256d-747a-4b36-a79a-57f47b6b79a4" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" x-ms-request-id="75c6256d-747a-4b36-a79a-57f47b6b79a4" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure request body="" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response x-ms-request-id="d61c62c2-734c-477f-ae73-0d9c1d39477c" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}" status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}" status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" x-ms-request-id="d61c62c2-734c-477f-ae73-0d9c1d39477c"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure request method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-z8slryd32g?api-version=2016-09-01" body=""
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-z8slryd32g?api-version=2016-09-01" x-ms-request-id="fa76eba9-67fd-4f84-a6d9-160b7f8ec1f6" body="" status="403 Forbidden"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-z8slryd32g?api-version=2016-09-01" x-ms-request-id="fa76eba9-67fd-4f84-a6d9-160b7f8ec1f6" body="" status="403 Forbidden" method="HEAD"
2018/02/12 07:45:24 ui: ==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:
2018/02/12 07:45:24 ui error: ==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/12 07:45:24 [INFO] (telemetry) ending azure-arm
2018/02/12 07:45:24 [INFO] (telemetry) found error: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/12 07:45:24 ui error: Build 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/12 07:45:24 Builds completed. Waiting on interrupt barrier...
2018/02/12 07:45:24 machine readable: error-count []string{"1"}
2018/02/12 07:45:24 ui error:
==> Some builds didn't complete successfully and had errors:
2018/02/12 07:45:24 machine readable: azure-arm,error []string{"resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: \"\" error: EOF"}
2018/02/12 07:45:24 ui error: --> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/12 07:45:24 ui:
==> Builds finished but no artifacts were created.
2018/02/12 07:45:24 [INFO] (telemetry) Finalizing.
2018/02/12 07:45:25 waiting for all plugin processes to complete...
2018/02/12 07:45:25 /usr/local/bin/packer: plugin process exited
2018/02/12 07:45:25 /usr/local/bin/packer: plugin process exited

Again, it looks like it is trying to create a Packer resource group (packer-Resource-Group-z8slryd32g)

2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-z8slryd32g?api-version=2016-09-01" x-ms-request-id="fa76eba9-67fd-4f84-a6d9-160b7f8ec1f6" body="" status="403 Forbidden"
2018/02/12 07:45:24 packer: 2018/02/12 07:45:24 Azure response request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-z8slryd32g?api-version=2016-09-01" x-ms-request-id="fa76eba9-67fd-4f84-a6d9-160b7f8ec1f6" body="" status="403 Forbidden" method="HEAD"

@mwhooker, is it possible to keep this ticket open until we get to the bottom of it, please ?

Thanks again!!

@mwhooker is it possible to re-open this case, please ?

Try

{
  "variables": {
    "build_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
  },
  "builders": [{
    "type": "azure-arm",
    "build_resource_group_name": "{{ user `build_resource_group_name` }}"
  }],
  "provisioners": [{
     }]
}

IIRC, you can't use env variables except to set user variables.

Thank you very much @SwampDragons for your reply. However ,it is still not working. Sorry to be such a pain.

File: env

#!/bin/bash
#
echo "Unset variables..."
unset ARM_CLIENT_ID
unset ARM_SUBSCRIPTION_ID
unset ARM_TENANT_ID
unset ARM_CLIENT_SECRET
unset ARM_RESOURCE_GROUP
unset ARM_STORAGE_ACCOUNT
rm packer.log
#
export ARM_CLIENT_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_SUBSCRIPTION_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_TENANT_ID="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_CLIENT_SECRET="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
export ARM_RESOURCE_GROUP="test-rg"
export ARM_STORAGE_ACCOUNT="svcstor1"
export ssh_user="test"
export ssh_pass="XXXXXXXXX"
export PACKER_LOG=1
export PACKER_LOG_PATH="packer.log"

File: rhel73.json

{
  "variables": {
    "client_id": "{{env `ARM_CLIENT_ID`}}",
    "build_resource_group_name": "{{env `ARM_RESOURCE_GROUP`}}",
    "client_secret": "{{env `ARM_CLIENT_SECRET`}}",
    "resource_group": "{{env `ARM_RESOURCE_GROUP`}}",
    "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}",
    "ssh_user": "XXXXXXX",
    "ssh_pass": "XXXXXXXX"
  },
  "builders": [{
    "type": "azure-arm",
    "client_id": "{{user `client_id`}}",
    "client_secret": "{{user `client_secret`}}",
    "build_resource_group_name": "{{user `ARM_RESOURCE_GROUP`}}",
    "subscription_id": "{{user `subscription_id`}}",
    "os_type": "Linux",
    "image_publisher": "RedHat",
    "image_offer": "RHEL",
      "image_sku": "7.3",
      "image_version": "latest",
      "ssh_pty": "true",
    "managed_image_resource_group_name": "{{user `resource_group`}}",
    "managed_image_name": "RHEL73",
    "azure_tags": {
        "dept": "XXXXXXXX",
        "task": "image deployment"
    },
    "location": "East US",
    "vm_size": "Standard_DS2_v2"
  }],
  "provisioners": [{
    "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "yum update -y",
      "wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm",
      "yum install -y epel-release-latest-7.noarch.rpm",
      "yum update -y",
      "yum install -y python python-pip jq ansible git",
      "git clone https://github.com/ansible/ansible.git",
      "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
    ],
    "inline_shebang": "/bin/sh -x",
    "type": "shell",
    "skip_clean": true
  }]
}

Output:

2018/02/14 12:42:28 [INFO] Packer version: 1.1.3
2018/02/14 12:42:28 Packer Target OS/Arch: darwin amd64
2018/02/14 12:42:28 Built with Go Version: go1.9.2
2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 Using internal plugin for amazon-ebs
2018/02/14 12:42:28 Using internal plugin for virtualbox-ovf
2018/02/14 12:42:28 Using internal plugin for azure-arm
2018/02/14 12:42:28 Using internal plugin for openstack
2018/02/14 12:42:28 Using internal plugin for profitbricks
2018/02/14 12:42:28 Using internal plugin for vmware-iso
2018/02/14 12:42:28 Using internal plugin for alicloud-ecs
2018/02/14 12:42:28 Using internal plugin for amazon-chroot
2018/02/14 12:42:28 Using internal plugin for amazon-ebsvolume
2018/02/14 12:42:28 Using internal plugin for lxc
2018/02/14 12:42:28 Using internal plugin for cloudstack
2018/02/14 12:42:28 Using internal plugin for file
2018/02/14 12:42:28 Using internal plugin for null
2018/02/14 12:42:28 Using internal plugin for oneandone
2018/02/14 12:42:28 Using internal plugin for triton
2018/02/14 12:42:28 Using internal plugin for docker
2018/02/14 12:42:28 Using internal plugin for googlecompute
2018/02/14 12:42:28 Using internal plugin for parallels-iso
2018/02/14 12:42:28 Using internal plugin for parallels-pvm
2018/02/14 12:42:28 Using internal plugin for vmware-vmx
2018/02/14 12:42:28 Using internal plugin for amazon-ebssurrogate
2018/02/14 12:42:28 Using internal plugin for amazon-instance
2018/02/14 12:42:28 Using internal plugin for digitalocean
2018/02/14 12:42:28 Using internal plugin for hyperv-iso
2018/02/14 12:42:28 Using internal plugin for hyperv-vmcx
2018/02/14 12:42:28 Using internal plugin for oracle-oci
2018/02/14 12:42:28 Using internal plugin for qemu
2018/02/14 12:42:28 Using internal plugin for virtualbox-iso
2018/02/14 12:42:28 Using internal plugin for lxd
2018/02/14 12:42:28 Using internal plugin for ansible
2018/02/14 12:42:28 Using internal plugin for chef-client
2018/02/14 12:42:28 Using internal plugin for windows-restart
2018/02/14 12:42:28 Using internal plugin for windows-shell
2018/02/14 12:42:28 Using internal plugin for file
2018/02/14 12:42:28 Using internal plugin for powershell
2018/02/14 12:42:28 Using internal plugin for shell
2018/02/14 12:42:28 Using internal plugin for ansible-local
2018/02/14 12:42:28 Using internal plugin for chef-solo
2018/02/14 12:42:28 Using internal plugin for puppet-server
2018/02/14 12:42:28 Using internal plugin for salt-masterless
2018/02/14 12:42:28 Using internal plugin for shell-local
2018/02/14 12:42:28 Using internal plugin for converge
2018/02/14 12:42:28 Using internal plugin for puppet-masterless
2018/02/14 12:42:28 Using internal plugin for docker-import
2018/02/14 12:42:28 Using internal plugin for googlecompute-export
2018/02/14 12:42:28 Using internal plugin for manifest
2018/02/14 12:42:28 Using internal plugin for vagrant-cloud
2018/02/14 12:42:28 Using internal plugin for vsphere-template
2018/02/14 12:42:28 Using internal plugin for amazon-import
2018/02/14 12:42:28 Using internal plugin for artifice
2018/02/14 12:42:28 Using internal plugin for compress
2018/02/14 12:42:28 Using internal plugin for docker-tag
2018/02/14 12:42:28 Using internal plugin for vagrant
2018/02/14 12:42:28 Using internal plugin for alicloud-import
2018/02/14 12:42:28 Using internal plugin for checksum
2018/02/14 12:42:28 Using internal plugin for docker-push
2018/02/14 12:42:28 Using internal plugin for docker-save
2018/02/14 12:42:28 Using internal plugin for shell-local
2018/02/14 12:42:28 Using internal plugin for atlas
2018/02/14 12:42:28 Using internal plugin for vsphere
2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 Attempting to open config file: /Users/XXXXXX/.packerconfig
2018/02/14 12:42:28 [WARN] Config file doesn't exist: /Users/XXXXXX/.packerconfig
2018/02/14 12:42:28 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[vmware-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-vmware-iso alicloud-ecs:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-alicloud-ecs parallels-pvm:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-parallels-pvm hyperv-vmcx:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-hyperv-vmcx amazon-ebs:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebs oneandone:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-oneandone googlecompute:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-googlecompute parallels-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-parallels-iso azure-arm:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-azure-arm amazon-ebsvolume:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebsvolume vmware-vmx:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-vmware-vmx amazon-chroot:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-chroot file:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-file amazon-instance:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-instance digitalocean:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-digitalocean hyperv-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-hyperv-iso cloudstack:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-cloudstack triton:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-triton lxc:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-lxc docker:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-docker qemu:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu virtualbox-ovf:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-virtualbox-ovf profitbricks:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-profitbricks null:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-null amazon-ebssurrogate:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebssurrogate virtualbox-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-virtualbox-iso lxd:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-lxd openstack:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-openstack oracle-oci:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-oracle-oci] PostProcessors:map[docker-save:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-save manifest:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-manifest googlecompute-export:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-googlecompute-export amazon-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-amazon-import compress:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-compress docker-tag:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-tag checksum:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-checksum docker-push:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-push shell-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-shell-local vsphere:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vsphere vagrant-cloud:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vagrant-cloud vsphere-template:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vsphere-template artifice:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-artifice vagrant:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vagrant alicloud-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-alicloud-import atlas:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-atlas docker-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-import] Provisioners:map[salt-masterless:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-salt-masterless chef-client:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-chef-client windows-restart:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-windows-restart ansible-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-ansible-local shell-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-shell-local windows-shell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-windows-shell powershell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-powershell converge:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-converge ansible:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-ansible puppet-server:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-puppet-server chef-solo:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-chef-solo puppet-masterless:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-puppet-masterless file:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-file shell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-shell]}
2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 Setting cache directory: /Users/XXXXXX/packer/azure/rgtest/packer_cache
2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 Loading builder: azure-arm
2018/02/14 12:42:28 Plugin could not be found. Checking same directory as executable.
2018/02/14 12:42:28 Current exe path: /usr/local/bin/packer
2018/02/14 12:42:28 Creating plugin client for path: /usr/local/bin/packer
2018/02/14 12:42:28 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-azure-arm"}
2018/02/14 12:42:28 Waiting for RPC address for: /usr/local/bin/packer
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 [INFO] Packer version: 1.1.3
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Packer Target OS/Arch: darwin amd64
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Built with Go Version: go1.9.2
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Attempting to open config file: /Users/XXXXXX/.packerconfig
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 [WARN] Config file doesn't exist: /Users/XXXXXX/.packerconfig
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[] PostProcessors:map[] Provisioners:map[]}
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Setting cache directory: /Users/XXXXXX/packer/azure/rgtest/packer_cache
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 args: []string{"packer-builder-azure-arm"}
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Plugin minimum port: 10000
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Plugin maximum port: 25000
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Plugin address: unix /var/folders/tw/w3mw4jxn1rd61llb63lc81bnblhflh/T/packer-plugin216466402
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Waiting for connection...
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Serving a plugin connection...
2018/02/14 12:42:28 Loading provisioner: shell
2018/02/14 12:42:28 Plugin could not be found. Checking same directory as executable.
2018/02/14 12:42:28 Current exe path: /usr/local/bin/packer
2018/02/14 12:42:28 Creating plugin client for path: /usr/local/bin/packer
2018/02/14 12:42:28 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2018/02/14 12:42:28 Waiting for RPC address for: /usr/local/bin/packer
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 [INFO] Packer version: 1.1.3
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Packer Target OS/Arch: darwin amd64
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Built with Go Version: go1.9.2
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Attempting to open config file: /Users/XXXXXX/.packerconfig
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 [WARN] Config file doesn't exist: /Users/XXXXXX/.packerconfig
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[] PostProcessors:map[] Provisioners:map[]}
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Setting cache directory: /Users/XXXXXX/packer/azure/rgtest/packer_cache
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 args: []string{"packer-provisioner-shell"}
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Plugin minimum port: 10000
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Plugin maximum port: 25000
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Detected home directory from env var: /Users/XXXXXX
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Plugin address: unix /var/folders/tw/w3mw4jxn1rd61llb63lc81bnblhflh/T/packer-plugin076280782
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Waiting for connection...
2018/02/14 12:42:28 packer: 2018/02/14 12:42:28 Serving a plugin connection...
2018/02/14 12:42:28 ui: azure-arm output will be in this color.
2018/02/14 12:42:28 ui:
2018/02/14 12:42:28 Build debug mode: false
2018/02/14 12:42:28 Force build: false
2018/02/14 12:42:28 On error:
2018/02/14 12:42:28 Preparing build: azure-arm
2018/02/14 12:42:28 Waiting on builds to complete...
2018/02/14 12:42:28 Starting build run: azure-arm
2018/02/14 12:42:28 Running builder: azure-arm
2018/02/14 12:42:28 [INFO] (telemetry) Starting builder azure-arm
2018/02/14 12:42:28 ui: ==> azure-arm: Running builder ...
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 :: Configuration
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ClientID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ClientSecret=********************************************
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ObjectID=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 TenantID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 SubscriptionID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 CaptureNamePrefix=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 CaptureContainerName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ImagePublisher=RedHat
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ImageOffer=RHEL
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ImageSku=7.3
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ImageVersion=latest
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ImageUrl=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 CustomManagedImageResourceGroupName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 CustomManagedImageName=f
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Location=East US
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 VMSize=Standard_DS2_v2
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ManagedImageResourceGroupName=test-rg
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ManagedImageName=RHEL73
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ManagedImageStorageAccountType=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 ResourceGroupName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 StorageAccount=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 TempComputeName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 TempResourceGroupName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 BuildResourceGroupName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 CloudEnvironmentName=Public
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 VirtualNetworkName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 VirtualNetworkSubnetName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 VirtualNetworkResourceGroupName=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 CustomDataFile=
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 OSType=Linux
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 UserName=packer
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Password=********************************
2018/02/14 12:42:30 ui:     azure-arm: Creating Azure Resource Manager (ARM) client ...
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure request body="" method="GET" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response x-ms-request-id="db377354-465b-423b-aab9-a3bdb6913d21" body="{\"id\":\"/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" x-ms-request-id="db377354-465b-423b-aab9-a3bdb6913d21" body="{\"id\":\"/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" status="200 OK" method="GET"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure request method="GET" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" body=""
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" x-ms-request-id="697408e6-f83c-466d-9dc7-4e94e1ac39e8" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" x-ms-request-id="697408e6-f83c-466d-9dc7-4e94e1ac39e8" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}" status="404 Not Found" method="GET"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure request method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-wcq8ndqhbj?api-version=2016-09-01" body=""
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response x-ms-request-id="15939d68-2fdb-4230-a664-3c362dd69413" body="" status="403 Forbidden" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-wcq8ndqhbj?api-version=2016-09-01"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response status="403 Forbidden" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-wcq8ndqhbj?api-version=2016-09-01" x-ms-request-id="15939d68-2fdb-4230-a664-3c362dd69413" body=""
2018/02/14 12:42:30 ui: ==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:
2018/02/14 12:42:30 ui error: ==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/14 12:42:30 [INFO] (telemetry) ending azure-arm
2018/02/14 12:42:30 [INFO] (telemetry) found error: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/14 12:42:30 ui error: Build 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/14 12:42:30 Builds completed. Waiting on interrupt barrier...
2018/02/14 12:42:30 machine readable: error-count []string{"1"}
2018/02/14 12:42:30 ui error:
==> Some builds didn't complete successfully and had errors:
2018/02/14 12:42:30 machine readable: azure-arm,error []string{"resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: \"\" error: EOF"}
2018/02/14 12:42:30 ui error: --> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/14 12:42:30 ui:
==> Builds finished but no artifacts were created.
2018/02/14 12:42:30 [INFO] (telemetry) Finalizing.
2018/02/14 12:42:31 waiting for all plugin processes to complete...
2018/02/14 12:42:31 /usr/local/bin/packer: plugin process exited
2018/02/14 12:42:31 /usr/local/bin/packer: plugin process exited

As before, it looks like it is trying to create a temp build resource group - packer-Resource-Group-wcq8ndqhbj

2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure request method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-wcq8ndqhbj?api-version=2016-09-01" body=""
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response x-ms-request-id="15939d68-2fdb-4230-a664-3c362dd69413" body="" status="403 Forbidden" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-wcq8ndqhbj?api-version=2016-09-01"
2018/02/14 12:42:30 packer: 2018/02/14 12:42:30 Azure response status="403 Forbidden" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourcegroups/packer-Resource-Group-wcq8ndqhbj?api-version=2016-09-01" x-ms-request-id="15939d68-2fdb-4230-a664-3c362dd69413" body=""

I just downloaded Packer 1.1.3, and verified it worked. Here's a working configuration. You will need to change the inputs, but maybe this will be enough to get it working for you.

{
    "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`}}",

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

            "build_resource_group_name": "my-keep-resource-group-test00",

            "capture_container_name": "images",
            "capture_name_prefix": "packer",

            "os_type": "linux",
            "image_publisher": "Canonical",
            "image_offer": "UbuntuServer",
            "image_sku": "16.04-LTS",

            "location": "South Central US",
            "vm_size": "Standard_DS1_v2"
        }
    ],
    "provisioners": [
        {
            "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
            "inline": [
                "df -ah",
                "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
            ],
            "inline_shebang": "/bin/sh -x",
            "type": "shell"
        }
    ]
}

I don't think your issue is the temporary packer resource group. ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found. looks an awful lot to me like the resource group you're passing in doesn't actually contain the image you want to use.

@SwampDragons thanks for your reply. RHEL73 is the destination image, not the source. I am using image_publisher + image_offer and in my case managed_image_name is the resultant of the image offered in azure.

 "managed_image_resource_group_name": "{{user `rgn`}}",
            "managed_image_name": "RHEL73",
            "os_type": "Linux",
            "image_publisher": "RedHat",
            "image_offer": "RHEL",
              "image_sku": "7.3",
              "image_version": "latest",

Were you able to work backwards from the config provided by @boumenot?

    "builders": [{
    "type": "azure-arm",
    "client_id": "REDACTED",
    "client_secret": "REDACTED",    
    "subscription_id": "REDACTED",
    "os_type": "Linux",
    "image_publisher": "RedHat",
    "image_offer": "RHEL",
      "image_sku": "7.3",
      "image_version": "latest",
      "ssh_pty": "true",
    "managed_image_resource_group_name": "PackerTestGroup",
    "managed_image_name": "PackerTestImage",
    "azure_tags": {
        "dept": "TSG",
        "task": "image deployment"
    },
    "location": "East US",
    "vm_size": "Standard_DS2_v2"
  }],

I was able to successfully run a build with this config ^^ ; if you remove location you can add in an existing build_resource_group. Either way, I can't reproduce your issue.

  "builders": [{
    "type": "azure-arm",
    "client_id": "REDACTED",
    "client_secret": "REDACTED",    
    "subscription_id": "REDACTED",
    "os_type": "Linux",
    "image_publisher": "RedHat",
    "image_offer": "RHEL",
      "image_sku": "7.3",
      "image_version": "latest",
      "ssh_pty": "true",
    "managed_image_resource_group_name": "PackerTestGroup",
    "managed_image_name": "PackerTestImage",
    "azure_tags": {
        "dept": "TSG",
        "task": "image deployment"
    },
    "build_resource_group_name": "PackerTestGroup",
    "vm_size": "Standard_DS2_v2"
  }],

Thanks for your answers @boumenot and @SwampDragons. I tested it both from Mac and Linux box, using 1.2.0 Packer version. At this point, it does not look like a syntax issue. I am getting 403 on packer group which was not supposed to be even created.

2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure request request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-09-01" body="" method="GET"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response x-ms-request-id="87491ece-8151-4434-ac7b-84e1a1bfa352" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/test-rg\",\"name\":\
"test-rg\",\"location\":\"eastus\",\"properties\":{\"provisioningState\":\"Succeeded\"}}" status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroup
s/test-rg?api-version=2016-09-01"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response status="200 OK" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/test-rg?api-version=2016-
09-01" x-ms-request-id="87491ece-8151-4434-ac7b-84e1a1bfa352" body="{\"id\":\"/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/test-rg\",\"name\":\"test-rg\",\"location\":\"eastus\",\"properties\":{\"
provisioningState\":\"Succeeded\"}}"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure request request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-v
ersion=2016-04-30-preview" body="" method="GET"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.\"}}
" status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/test-rg/providers/Microsoft.Compute/images/RHEL73?api-version=2016-04-30-previe
w" x-ms-request-id="1186acaf-0b08-4fb4-b712-8948ea21a0aa"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response status="404 Not Found" method="GET" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourceGroups/test-rg/providers/
Microsoft.Compute/images/RHEL73?api-version=2016-04-30-preview" x-ms-request-id="1186acaf-0b08-4fb4-b712-8948ea21a0aa" body="{\"error\":{\"code\":\"ResourceNotFound\",\"message\":\"The Resource 'Microsoft.Compute/images/RHEL
73' under resource group 'test-rg' was not found.\"}}"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure request body="" method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/packer-Resource-Group-jh9dqp5djs?api
-version=2016-09-01"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/packer-Resource-Group-jh9dqp5djs?api-version=2016-09-01"
x-ms-request-id="6bf29298-1d75-40be-90f5-9bf716f8b6bc" body="" status="403 Forbidden" method="HEAD"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/packer-Resource-Group-jh9dqp5djs?api-versio
n=2016-09-01" x-ms-request-id="6bf29298-1d75-40be-90f5-9bf716f8b6bc" body="" status="403 Forbidden"
2018/02/15 08:05:11 ui: ==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:
2018/02/15 08:05:11 ui error: ==> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/15 08:05:11 [INFO] (telemetry) ending azure-arm
2018/02/15 08:05:11 [INFO] (telemetry) found error: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/15 08:05:11 ui error: Build 'azure-arm' errored: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error
: EOF
2018/02/15 08:05:11 Builds completed. Waiting on interrupt barrier...
2018/02/15 08:05:11 machine readable: error-count []string{"1"}
2018/02/15 08:05:11 ui error:
==> Some builds didn't complete successfully and had errors:
2018/02/15 08:05:11 machine readable: azure-arm,error []string{"resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: \"\" er
ror: EOF"}
2018/02/15 08:05:11 ui error: --> azure-arm: resources.GroupsClient#CheckExistence: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: error response cannot be parsed: "" error: EOF
2018/02/15 08:05:11 ui:
==> Builds finished but no artifacts were created.
2018/02/15 08:05:11 [INFO] (telemetry) Finalizing.
2018/02/15 08:05:11 waiting for all plugin processes to complete...
2018/02/15 08:05:11 /usr/sbin/packer: plugin process exited
2018/02/15 08:05:11 /usr/sbin/packer: plugin process exited

To zoom in:

2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/packer-Resource-Group-jh9dqp5djs?api-version=2016-09-01"
x-ms-request-id="6bf29298-1d75-40be-90f5-9bf716f8b6bc" body="" status="403 Forbidden" method="HEAD"
2018/02/15 08:05:11 packer: 2018/02/15 08:05:11 Azure response method="HEAD" request="https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX/resourcegroups/packer-Resource-Group-jh9dqp5djs?api-versio
n=2016-09-01" x-ms-request-id="6bf29298-1d75-40be-90f5-9bf716f8b6bc" body="" status="403 Forbidden"
2018/02/15 08:05:11 ui: ==> azure-arm: ERROR: -> ResourceNotFound : The Resource 'Microsoft.Compute/images/RHEL73' under resource group 'test-rg' was not found.
==> azure-arm:

Packer is clearly referencing packer-Resource-Group-jh9dqp5djs and giving me 403. Also, it is for some reason is looking for RHEL73 image under group test-rg which is TO BE created as a destination build image.

Just to level set:

  • I am locked to Azure resource group test-rg. I cannot operate outside it.
  • I have full access to Azure resource group test-rg

It looks to me that Packer is still trying to create a resource group outside the build_resource_group_name which is resulting in 403.

I give up. It does now work for me. I have to come up with other ways to build an image. Thanks so much for all the help.

AHA! image under group test-rg which is TO BE created as a destination build image. -- so the test-rg doesn't already exist? When that happens, (@boumenot probably knows better than me here) packer builds in a temporary group first, I believe. I was assuming that your resource group already existed, since there were security reasons preventing you from going outside of it. Is it possible for you to create the resource group from the Azure CLI or UI before you run the packer build? Is this resource group going to be one that changes regularly? I wasn't able to reproduce above because I'd already created the group PackerTestGroup in Azure before running my build.

Oh geez, misread again. It does already exist for you. :-/

I understand your frustration and I'm sorry we weren't able to figure this out for you. All I can say is that the config here still doesn't even look valid to me on packer 1.1.3 OR 1.2.0 (I get an error if I try to run an azure build with both the build_resource_group_name and the location flags set). Given that, I can't reproduce exactly what you're experiencing, which frustrates me too because I really do want to get to the bottom of this for you. That said, I understand you not wanting to spend more time on this.

The Azure builder is still under active development and over time it'll mature to cover all the edge cases like yours; hopefully you'll give us another chance in the future when that's the case. I'm going to close this ticket for now since you don't want to continue working through it with us, but if you change your mind we're here :)

@SwampDragons , you're absolutely right. If I do remove 'location' it does work. This 403 error was completely throwing me off. Thank you so much @SwampDragons and @boumenot for your help!!

For those who are getting the same error but experiencing "different" problem. My problem in this case was the service principal is not added as a contributor in subscription.

I am facing same issue when I try to build packer image. Is it due to roles issue with the SP?

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings