Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting Windows VM fails: "The parsed Resource ID was missing a value for the segment at position 2" #590

Closed
DinnyMN opened this issue Jan 24, 2025 · 3 comments
Labels
question Further information is requested upstream-provider

Comments

@DinnyMN
Copy link

DinnyMN commented Jan 24, 2025

When exporting a VM I get an 'Failed to import' error. The os disk fails to import due to casing of resourceGroup.

Is this an issue here or on an upstream provider?

/subscriptions/12345678-1234/resourceGroups/example-resource-group/providers/Microsoft.Compute/disks/diskValue
/subscriptions/aaaa-bbbb-cccc/resourcegroups/rg-test/providers/Microsoft.Compute/disks/vm-test_OsDisk

Error: Failed to import /subscriptions/aaaa-bbbb-cccc/resourceGroups/rg-test/providers/Microsoft.Compute/virtualMachines/vm-test as azurerm_windows_virtual_machine.vm-test: exit status 1

Error: flattening `os_disk`: parsing "/subscriptions/aaaa-bbbb-cccc/resourcegroups/rg-test/providers/Microsoft.Compute/disks/vm-test_OsDisk": parsing segment "staticResourceGroups": parsing the ManagedDisk ID: the segment at position 2 didn't match

Expected a ManagedDisk ID that matched:

> /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/disks/diskValue

However this value was provided:

> /subscriptions/aaaa-bbbb-cccc/resourcegroups/rg-test/providers/Microsoft.Compute/disks/vm-test_OsDisk

The parsed Resource ID was missing a value for the segment at position 2
(which should be the literal value "resourceGroups").
@DinnyMN
Copy link
Author

DinnyMN commented Jan 24, 2025

I found just importing the resource fails. This seems like an issue with the terraform azurerm provider itself

terraform import "azurerm_windows_virtual_machine.vm-test" "/subscriptions/aaaa-bbbb-cccc/resourceGroups/rg-test/providers/Microsoft.Compute/virtualMachines/vm-test"

@magodo magodo added question Further information is requested upstream-provider labels Jan 24, 2025
@magodo
Copy link
Collaborator

magodo commented Jan 24, 2025

@DinnyMN The provider has a strict requirement for the resource id casings. Presumably your resource is created in an old provider version, or even not via Terraform. If that is the case, I'll suggest to use tools like Azure CLI to make a PUT request to the VM, with all the payload unchanged, except the resourcegroup, changed into resourceGroup, for the properties.storageProfile.osDisk.managedDisk.id.

@joshd-emergent
Copy link

We updated the azurerm provider to handle this which was release in 4.17.0. That solved our issue here.

aztfexport --provider-version 4.17.0 ...

hashicorp/terraform-provider-azurerm#28592

@DinnyMN DinnyMN closed this as completed Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested upstream-provider
Projects
None yet
Development

No branches or pull requests

3 participants