hashicorp / hashicorp/packer-plugin-azure

SourceImageName isn't populated when source image is a image gallery artifact with version set to 'latest'

Open
#485 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
63
Forks
103
PR merge metrics
No merged PRs in 30d

Description

#### Overview of the Issue

A paragraph or two about the issue you're experiencing.

Since version v2.3.1 I've been getting the below error message.

```
Failed to fetch source gallery image from Azure API, HCP Packer will not be able to track the ancestry of this build: unexpected status 404 (404 Not Found) with error: ResourceNotFound: The Resource 'Microsoft.Compute/galleries/GALLERY_NAME/images/IMAGE_NAME/versions/latest' under resource group 'RESOURCE_GROUP_NAME' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
```

This may be related to the commits in v2.3.1 and v2.3.2. In version v2.3.2, which allowed us to test HCP Packer using Azure Compute Galleries/SIGs properly, it acts like you have to have some type of HCP packer variable or setting enabled; otherwise, you'll get this error message.

#### Reproduction Steps

Use a simple packer template with a pre-existing image in a SIG as its source and you should get this error message if not using HCP packer.

### Plugin and Packer version

packer version: `v1.12.0`
plugin(s): github.com/hashicorp/azure
* version: v2.3.2

### Simplified Packer Buildfile

sources.pkr.hcl

```python
source "azure-arm" "hib" {
communicator = "ssh"
ssh_username = "packer"
ssh_password = var.password
build_resource_group_name = var.build_resource_group_name
os_type = "Linux"
use_azure_cli_auth = false
virtual_network_name = var.virtual_network_name
virtual_network_resource_group_name = var.virtual_network_resource_group_name
virtual_network_subnet_name = var.virtual_network_subnet_name

shared_image_gallery {
subscription = var.src_subscription
resource_group = var.src_resource_group
gallery_name = var.src_gallery_name
image_name = var.src_image_name
image_version = var.src_image_version
}

shared_image_gallery_destination {
subscription = var.dest_subscription
resource_group = var.dest_resource_group
gallery_name = var.dest_gallery_name
image_name = var.dest_image_name
image_version = var.dest_image_version
replication_regions = var.dest_replication_regions
}
}
```

### Operating system and Environment details

Host: Ubuntu 24.04
Image VM: RHEL 8.10
Arch: x64

### Log Fragments and crash.log files

NA

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the simplified sources.pkr.hcl configuration, using an Azure Compute Gallery source image whose version is set to "latest". Inspect the Azure API request that produces the 404 and determine why SourceImageName is not populated. Done means the source gallery image is handled correctly without requiring HCP Packer settings and the reported error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, go
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.