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

Operation ‘powerOff’ is not allowed (409 Conflict) #28218

Open
1 task done
onur-ozguzel opened this issue Dec 9, 2024 · 6 comments
Open
1 task done

Operation ‘powerOff’ is not allowed (409 Conflict) #28218

onur-ozguzel opened this issue Dec 9, 2024 · 6 comments
Labels
service/virtual-machine upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR v/3.x

Comments

@onur-ozguzel
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.7.5

AzureRM Provider Version

3.117.0

Affected Resource(s)/Data Source(s)

azurerm_windows_virtual_machine.windows_vm

Terraform Configuration Files

N/A

Debug Output/Panic Output

╷
│ Error: powering off Windows Virtual Machine (Subscription: "xxx"
│ Resource Group Name: "yyy"
│ Virtual Machine Name: "zzz"): performing PowerOff: unexpected status 409 (409 Conflict) with error: OperationNotAllowed: Operation 'powerOff' is not allowed on VM 'zzz' since the VM is either deallocated or marked to be deallocated. Please refer to https://aka.ms/vmpowerstates  to learn about different VM power states.
│ 
│ 
╵

Expected Behaviour

After VM generalization, destroy command should destroy the VM.

Actual Behaviour

I started to get the error above since 6 December 24. Before that it was working just as expected.

Steps to Reproduce

  • Create a VM,
  • Generalize that VM (either via a script or Azure UI)
  • Run destroy command (terraform plan -destroy xxx)

Important Factoids

No response

References

No response

@github-actions github-actions bot added the v/3.x label Dec 9, 2024
@3wweiweiwu
Copy link

3wweiweiwu commented Dec 9, 2024

I saw similar issue. It seems like MS change their API behavior. In the past, we can shutdown VM regardless the VM state. Currently, they only allow VM shutdown on turned on VM.

As a workaround, we need to turn on the VM before we can shutdown without any error. Luckily, they don't force us to turn off VM before we can turn it on

@rcskosir rcskosir added service/virtual-machine upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR labels Dec 9, 2024
@gwynbleide
Copy link

This is an issue with every VM in deallocated state. I tested this with latest 4.13.0 provider as well. But it does not matter given this is an API issue apparently.

@TitusZorg
Copy link

I also got this problem in two different environments. :(
Terraform v1.10.1
hashicorp/azurerm v4.13.0 (signed by HashiCorp)

@ms-zhenhua
Copy link
Contributor

Hi @onur-ozguzel, FWIW, as a workaround, you may try to set graceful_shutdown or skip_shutdown_and_force_delete to skip the power-off step.

@j81blog
Copy link

j81blog commented Dec 13, 2024

graceful_shutdown doesn't seem to work, skip_shutdown_and_force_delete does.

provider "azurerm" {
  features {
    virtual_machine {
      skip_shutdown_and_force_delete = true
    }
  }
}

@onur-ozguzel
Copy link
Author

graceful_shutdown doesn't seem to work, skip_shutdown_and_force_delete does.

provider "azurerm" {
  features {
    virtual_machine {
      skip_shutdown_and_force_delete = true
    }
  }
}

In my case skip_shutdown_and_force_delete also worked. Thanks @j81blog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/virtual-machine upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR v/3.x
Projects
None yet
Development

No branches or pull requests

7 participants