Code="DeploymentFailed" Message="At least one resource deployment operation failed.

pacecomposed 0 Reputation points
2024-02-28T18:02:42.7233333+00:00

I am trying to create images in azure using packer. I am getting the Code="DeploymentFailed" Message="At least one resource deployment operation failed error now and then. If I change the resource group to deploy the image to it starts working and then after few attempts it stops working. Below is the complete error:

Build 'azure-arm.GoldenImage' errored after 2 minutes 20 seconds: polling after CreateOrUpdate: Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details." Target="/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/GoldenImage-Packer-Build-Rg/providers/Microsoft.Resources/deployments/pkrdpiiiokqtc33" Details=[{"code":"InvalidResourceReference","details":[],"message":"Resource /subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/ProdPriv/providers/Microsoft.Network/virtualNetworks/ProdPriv/subnets/ProdSubnet1 referenced by resource /subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/Prod-GoldenImage-Packer-Build-Rg/providers/Microsoft.Network/networkInterfaces/pkrniiiiokqtc33 was not found. Please make sure that the referenced resource exists, and that both resources are in the same region."}]


I confirm that everything is in the same region and no doubt about that because same packer template with different variables is working which also gives the same above error sometimes. And I again need to change around the resource groups and images names and then it starts working all of a sudden. Code:

source "azure-arm" "GoldenImage" {

  communicator    = "winrm"
  image_offer     = "WindowsServer"
  image_publisher = "MicrosoftWindowsServer"
  image_sku       = "2019-Datacenter"

  managed_image_name                 = "ProdWin2019DatacenterGoldenImage${var.appType}${local.date}"
  managed_image_resource_group_name  = var.managed_image_resource_group_name
  managed_image_storage_account_type = var.managed_image_storage_account_type

  os_type        = "Windows"
  vm_size        = "Standard_D4s_v3" #"Standard_B4ms"
  winrm_insecure = true
  winrm_timeout  = "5m"
  winrm_use_ssl  = true
  winrm_username = "packer"

  subscription_id    = var.subscription_id
  use_azure_cli_auth = true
  azure_tags         = var.azure_tags

  location                 = var.location
  temp_resource_group_name = "${var.Environment}-${var.appType}-RMIS-GoldenImage-Packer-Build-Rg"

  virtual_network_name                = var.virtual_network_name
  virtual_network_subnet_name         = var.virtual_network_subnet_name
  virtual_network_resource_group_name = var.virtual_network_resource_group_name
}

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,798 questions
{count} votes

1 answer

Sort by: Most helpful
  1. v-vvellanki-MSFT 4,920 Reputation points Microsoft Vendor
    2024-02-29T11:47:29.1133333+00:00

    Hi @pacecomposed,

    Thanks for contacting Microsoft Q&A platform.

    The error message you have provided indicates that the deployment failed because a resource referenced by another resource was not found. Specifically, the subnet.

    You can follow below steps to troubleshoot the issue.

    • Ensure that the referenced virtual network subnet exists in your Azure environment. You can check this in the Azure portal or by using Azure CLI or Azure PowerShell commands.
    • Confirm that both the resource being deployed and the referenced resource are located in the same Azure region. If they are not in the same region, you will need to update the deployment template or configuration to ensure consistency.
    • Double-check the resource names and resource IDs referenced in your deployment template or configuration to ensure accuracy. There might be a typo or incorrect reference causing the deployment failure.
    • Review the detailed deployment logs to identify any additional errors or warnings that might provide more insight into the root cause of the issue. You can find deployment logs in the Azure portal or by using Azure CLI commands.

    Hope this helps you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.