SOLVED

Azure Policy - Enable Autoshutdown on Azure VM

Brass Contributor

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

8 Replies
@Luke Murray

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?

I haven't personally tried it, but it should work. You can always deploy it to a Resource Group as a test.
It doesnt work.
The VM without an Autoshutdown Configuration ist listen at compliant.

Do you have any more Idea?

@Phil123I'm just testing this. Did you set a Remediation Task as part of the deployment so that it can deploy the ComputeVmShutdownTask, if it doesn't exist and make them compliant?

 

LukeMurray_0-1651701858721.png

LukeMurray_1-1651701881358.png

 

 

 

Did it work as you?

I have done so many tests. I must test it again.
When you say that its work than have i forgot the remediation task i think.
best response confirmed by Phil123 (Brass Contributor)
Solution
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.
Really cool.
Thanks for your help. It was many helpfully.

P.s. I have another question about Policys and Extensions.
I will open a new case for this. Maybe you can help me at this Point to.

Thanks.

1 best response

Accepted Solutions
best response confirmed by Phil123 (Brass Contributor)
Solution
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.

View solution in original post