Packer: custom_managed_image_name error... > azure builder

Created on 30 May 2018  ยท  6Comments  ยท  Source: hashicorp/packer

Packer Version: 1.2.4
Host: Ubuntu

Running Packer on a Azure custom image fails with "The Image '/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5' cannot be found.\"\r\n }\r\n}"}] even though that exact image resource id exists. The error occurs with a interactive login or using a SPN.

Terminal Output

Debug mode enabled. Builds will not be parallelized.
azure-arm output will be in this color.

==> azure-arm: Running builder ...
azure-arm: Creating Azure Resource Manager (ARM) client ...
azure-arm: temp admin user: 'packer'
azure-arm: temp admin password: 'lalalalalalala'
azure-arm: temp ssh key: azure-arm-pkrvmwz70rv5k2c.pem
==> azure-arm: Creating resource group ...
==> azure-arm: -> ResourceGroupName : 'packer-Resource-Group-wz70rv5k2c'
==> azure-arm: -> Location : 'USGov Virginia'
==> azure-arm: -> Tags :
==> azure-arm: Pausing after run of step 'StepCreateResourceGroup'. Press enter to continue.
==> azure-arm: Validating deployment template ...
==> azure-arm: -> ResourceGroupName : 'packer-Resource-Group-wz70rv5k2c'
==> azure-arm: -> DeploymentName : 'pkrdpwz70rv5k2c'
==> azure-arm: Pausing after run of step 'StepValidateTemplate'. Press enter to continue.
==> azure-arm: Deploying deployment template ...
==> azure-arm: -> ResourceGroupName : 'packer-Resource-Group-wz70rv5k2c'
==> azure-arm: -> DeploymentName : 'pkrdpwz70rv5k2c'
==> azure-arm: ERROR: -> DeploymentFailed : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
==> azure-arm: ERROR: -> NotFound
==> azure-arm: ERROR: -> NotFound : The Image '/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5' cannot be found.
==> azure-arm:
==> azure-arm: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details." Details=[{"code":"NotFound","message":"{\r\n \"error\": {\r\n \"code\": \"NotFound\",\r\n \"message\": \"The Image '/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5' cannot be found.\"\r\n }\r\n}"}]
==> azure-arm: Pausing before cleanup of step 'StepValidateTemplate'. Press enter to continue.
==> azure-arm: Pausing before cleanup of step 'StepCreateResourceGroup'. Press enter to continue.
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...

Running az image show with the id listed in the error show that the resource exists.

az image show --ids /subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5
{
"additionalProperties": {},
"id": "/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5",
"location": "USGovTexas",
"name": "baseCentos_7.5",
"provisioningState": "Succeeded",
"resourceGroup": "CustomImage",
"sourceVirtualMachine": null,
"storageProfile": {
"additionalProperties": {},
"dataDisks": [],
"osDisk": {
"additionalProperties": {},
"blobUri": "https://customcentimg.blob.core.usgovcloudapi.net/disks/baseCentos_7.5.vhd",
"caching": "None",
"diskSizeGb": 32,
"managedDisk": null,
"osState": "Generalized",
"osType": "Linux",
"snapshot": null,
"storageAccountType": "Standard_LRS"
},
"zoneResilient": null
},
"tags": {},
"type": "Microsoft.Compute/images"
}

Packer Template

{
"variables": {
"deployment_code": "",
"resource_group": "",
"subscription_id": "",
"location": "",
"cloud_environment_name": "Public"
},
"builders": [
{
"type": "azure-arm",
"subscription_id": "{{user subscription_id}}",
"cloud_environment_name": "{{user cloud_environment_name}}",
"managed_image_resource_group_name": "{{user resource_group}}",
"managed_image_name": "Centos_Custom_7.5_{{isotime \"2006_01_02_15_04\"}}",
"managed_image_storage_account_type": "Premium_LRS",
"os_type": "Linux",
"custom_managed_image_resource_group_name": "CustomImage",
"custom_managed_image_name": "baseCentos_7.5",
"location": "{{user location}}",
"vm_size": "Standard_DS1_v2"
}
],
"provisioners": [
{
"execute_command": "echo '{{user ssh_pass}}' | {{ .Vars }} sudo -S -E sh '{{ .Path }}'",
"inline": [
"yum update -y",
"/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync"
],
"inline_shebang": "/bin/sh -x",
"type": "shell",
"skip_clean": true
}
]
}

Packer Logs - here

bug buildeazure

Most helpful comment

@SwampDragons - I just tested on v 1.2.3 and it was occurring then as well.

saadmin@Rohrer-D:/mnt/c/Projects/Terraform/src/packer/centos$ packer --version
1.2.3

saadmin@Rohrer-D:/mnt/c/Projects/Terraform/src/packer/centos$ sudo packer build -debug -var-file secrets.json -var-file sus1.json centos.json
Debug mode enabled. Builds will not be parallelized.
azure-arm output will be in this color.

==> azure-arm: Running builder ...
    azure-arm: Creating Azure Resource Manager (ARM) client ...
    azure-arm: temp admin user: 'packer'
    azure-arm: temp admin password: 'lalalalalala'
    azure-arm: temp ssh key: azure-arm-pkrvmy23scvz6mj.pem
==> azure-arm: Creating resource group ...
==> azure-arm:  -> ResourceGroupName : 'packer-Resource-Group-y23scvz6mj'
==> azure-arm:  -> Location          : 'USGov Virginia'
==> azure-arm:  -> Tags              :
==> azure-arm: Pausing after run of step 'StepCreateResourceGroup'. Press enter to continue.
==> azure-arm: Validating deployment template ...
==> azure-arm:  -> ResourceGroupName : 'packer-Resource-Group-y23scvz6mj'
==> azure-arm:  -> DeploymentName    : 'pkrdpy23scvz6mj'
==> azure-arm: Pausing after run of step 'StepValidateTemplate'. Press enter to continue.
==> azure-arm: Deploying deployment template ...
==> azure-arm:  -> ResourceGroupName : 'packer-Resource-Group-y23scvz6mj'
==> azure-arm:  -> DeploymentName    : 'pkrdpy23scvz6mj'
==> azure-arm: ERROR: -> DeploymentFailed : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
==> azure-arm: ERROR:   -> NotFound
==> azure-arm: ERROR:   -> NotFound : The Image '/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5' cannot be found.
==> azure-arm:
==> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."
==> azure-arm: Pausing before cleanup of step 'StepValidateTemplate'. Press enter to continue.
==> azure-arm: Pausing before cleanup of step 'StepCreateResourceGroup'. Press enter to continue.
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...
==> azure-arm: Resource group has been deleted.
Build 'azure-arm' errored: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."

==> Some builds didn't complete successfully and had errors:
--> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."

==> Builds finished but no artifacts were created.

All 6 comments

Thanks for opening. Is this a regression in 1.2.4 or did it not work in 1.2.3 either?

@SwampDragons - I just tested on v 1.2.3 and it was occurring then as well.

saadmin@Rohrer-D:/mnt/c/Projects/Terraform/src/packer/centos$ packer --version
1.2.3

saadmin@Rohrer-D:/mnt/c/Projects/Terraform/src/packer/centos$ sudo packer build -debug -var-file secrets.json -var-file sus1.json centos.json
Debug mode enabled. Builds will not be parallelized.
azure-arm output will be in this color.

==> azure-arm: Running builder ...
    azure-arm: Creating Azure Resource Manager (ARM) client ...
    azure-arm: temp admin user: 'packer'
    azure-arm: temp admin password: 'lalalalalala'
    azure-arm: temp ssh key: azure-arm-pkrvmy23scvz6mj.pem
==> azure-arm: Creating resource group ...
==> azure-arm:  -> ResourceGroupName : 'packer-Resource-Group-y23scvz6mj'
==> azure-arm:  -> Location          : 'USGov Virginia'
==> azure-arm:  -> Tags              :
==> azure-arm: Pausing after run of step 'StepCreateResourceGroup'. Press enter to continue.
==> azure-arm: Validating deployment template ...
==> azure-arm:  -> ResourceGroupName : 'packer-Resource-Group-y23scvz6mj'
==> azure-arm:  -> DeploymentName    : 'pkrdpy23scvz6mj'
==> azure-arm: Pausing after run of step 'StepValidateTemplate'. Press enter to continue.
==> azure-arm: Deploying deployment template ...
==> azure-arm:  -> ResourceGroupName : 'packer-Resource-Group-y23scvz6mj'
==> azure-arm:  -> DeploymentName    : 'pkrdpy23scvz6mj'
==> azure-arm: ERROR: -> DeploymentFailed : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
==> azure-arm: ERROR:   -> NotFound
==> azure-arm: ERROR:   -> NotFound : The Image '/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5' cannot be found.
==> azure-arm:
==> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."
==> azure-arm: Pausing before cleanup of step 'StepValidateTemplate'. Press enter to continue.
==> azure-arm: Pausing before cleanup of step 'StepCreateResourceGroup'. Press enter to continue.
==> azure-arm:
==> azure-arm: Cleanup requested, deleting resource group ...
==> azure-arm: Resource group has been deleted.
Build 'azure-arm' errored: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."

==> Some builds didn't complete successfully and had errors:
--> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."

==> Builds finished but no artifacts were created.

I tried this out in public cloud and it works, based on the logs that you have given it seems that you are trying to create a resource group in one region and accessing the image from another region. This is not supported in Azure . You need to have the custom image in the same region. Below is the information from your logs and I was able to repo this by changing regions as well

==> azure-arm: -> ResourceGroupName : 'packer-Resource-Group-wz70rv5k2c'
==> azure-arm: -> Location : 'USGov Virginia'

{
"additionalProperties": {},
"id": "/subscriptions/75406810-f3e6-42fa-97c6-e9027e0a0a45/resourceGroups/CustomImage/providers/Microsoft.Compute/images/baseCentos_7.5",
"location": "USGovTexas",

Please create the image in USGov Virginia and that should fix it.

@boumenot please close this issue as this is user error, though not sure if we can put a better error message as the error happens in the template execution. Thoughts?

anyone know what causing this

[debug]==> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details."

Hit with the same issue, when i try to update custom image by implementing CI/CD. Can anyone suggest with the fix? I have placed my image and resource group in same region.

Build immutable machine image logs:
2019-12-02T09:08:51.9062988Z
2019-12-02T09:10:58.1774772Z ==> azure-arm: Getting the certificate's URL ...
2019-12-02T09:10:58.1775710Z ==> azure-arm: -> Key Vault Name : 'pkrkv8lnzhx71nd'
2019-12-02T09:10:58.1775831Z ==> azure-arm: -> Key Vault Secret Name : 'packerKeyVaultSecret'
2019-12-02T09:10:58.1776155Z
2019-12-02T09:10:59.5787361Z ==> azure-arm: -> Certificate URL : 'https://pkrkv8lnzhx71nd.vault.azure.net/secrets/packerKeyVaultSecret/626de9f8dcfe4766b3164964f83effe3'
2019-12-02T09:10:59.5787613Z
2019-12-02T09:10:59.5788364Z ==> azure-arm: Setting the certificate's URL ...
2019-12-02T09:10:59.5788441Z
2019-12-02T09:10:59.5792900Z ==> azure-arm: Validating deployment template ...
2019-12-02T09:10:59.5793202Z
2019-12-02T09:10:59.5799014Z ==> azure-arm: -> ResourceGroupName : 'packer-Resource-Group-8lnzhx71nd'
2019-12-02T09:10:59.5799338Z
2019-12-02T09:10:59.5803292Z ==> azure-arm: -> DeploymentName : 'pkrdp8lnzhx71nd'
2019-12-02T09:10:59.5804075Z
2019-12-02T09:11:01.2436279Z ==> azure-arm: Deploying deployment template ...
2019-12-02T09:11:01.2436865Z
2019-12-02T09:11:01.2447458Z ==> azure-arm: -> ResourceGroupName : 'packer-Resource-Group-8lnzhx71nd'
2019-12-02T09:11:01.2448546Z
2019-12-02T09:11:01.2450409Z ==> azure-arm: -> DeploymentName : 'pkrdp8lnzhx71nd'
2019-12-02T09:11:01.2450498Z
2019-12-02T09:53:22.8895949Z ==> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details."
2019-12-02T09:53:22.8898959Z ==> azure-arm:
2019-12-02T09:53:22.8899329Z
2019-12-02T09:53:22.8904635Z ==> azure-arm: Cleanup requested, deleting resource group ...
2019-12-02T09:53:22.8904821Z
2019-12-02T09:57:31.5220858Z ==> azure-arm: Resource group has been deleted.
2019-12-02T09:57:31.5221898Z Build 'azure-arm' errored: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details."
2019-12-02T09:57:31.5222268Z
2019-12-02T09:57:31.5222346Z ==> Some builds didn't complete successfully and had errors:
2019-12-02T09:57:31.5222618Z --> azure-arm: resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details."
2019-12-02T09:57:31.5222796Z
2019-12-02T09:57:31.5222868Z ==> Builds finished but no artifacts were created.
2019-12-02T09:57:31.5223792Z
2019-12-02T09:57:31.5680892Z ##[error]Error: D:\a_temp\1575277721063\packer\packer.exe failed with return code: 1
2019-12-02T09:57:31.5701912Z ##[section]Finishing: Build immutable machine image

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