Forum Discussion

Phil123's avatar
Phil123
Brass Contributor
May 02, 2022
Solved

Azure Policy - Enable Autoshutdown on Azure VM

Hello,

 

it is possible to activate the Azure VM Autoshutdown Function with an Azure Policy?

I found always articles with an DevTest Lab. But i would like to use an AZure Policy at the Production Subscription to can found VMs without an Azure AutoShutdown Configuration.

 

Thanks.

 

Best Regards,
Phil

  • Hi, Phil.

    Yes, it did!

    Delete the assignment, re-run it again, and create your Remediation Task with your System Assigned identity. Although not required, if you have an AutoShutdown already configured, you can just set it to 'None' to let the policy configure the correct time etc in one place.

8 Replies

  • Yes, you can. This blog post from Tao Yang, https://blog.tyang.org/2019/06/02/new-azure-policy-definition-deploy-vm-shutdown-schedule/ - help explains it. He has also written the Azure Policy JSON for you: https://github.com/tyconsulting/azurepolicy/blob/master/policy-definitions/deploy-vm-shutdown-schedule/azurepolicy.json
    • Phil123's avatar
      Phil123
      Brass Contributor
      lukemurraynz

      Thanks for this Answer.
      I found this Website to. But im a little bit confused about the Fields in the JSON File.
      They always use the "DevtestLab" Fields.

      Can i use this also for the normal Azure Tenant?

      • lukemurraynz's avatar
        lukemurraynz
        Learn Expert
        I haven't personally tried it, but it should work. You can always deploy it to a Resource Group as a test.

Resources