Aztfexport fails to export resources when there are two data disk or two nic even if I use --append flag in the command

!thr@ 0 Reputation points
2025-06-17T11:10:10.3466667+00:00

Aztfexport fails to export resources when there are two data disk or two nic attached to an azure vm even if I use --append flag in the command.

Error: [aztfexport] 2025/06/17 08:39:23 DeInitializing...

Error: parallel importing: 1 error occurred:

  • task handler error: failed to merge state file: 1 error occurred:
  • resource azurerm_managed_disk.res-0 is defined in both state files C:\Windows\SystemTemp\34534\terraform.tfstate and C:\Windows\SystemTemp\aztfexport-2342\terraform.tfstate
aztfexport resource --append --generate-import-block --plain-ui -n -o newfolder "$osdiskid"

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

1 answer

Sort by: Most helpful
  1. !thr@ 0 Reputation points
    2025-06-19T08:53:14.5+00:00

    Hi, Thanks for the response.

    My scenario is, am creating a pipeline that has to import the azure vm and its attached resources using aztfexport. The vm has two data disk attached to it. Now when I import the data disk, I have to use --name-pattern flag, as the default "res-0" is already used to import virtual machine resource. Now when I use the --generate-import-block flag, its create a import.tf file with two data disk resource name as res-0 and the terraform plan throws error as it doesn't exist but it exist with the different name specified in --name-pattern.

    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.