How to exclude VM auto-shutdown from Tag policy

Elliott Kurtz 5 Reputation points
2023-09-18T20:30:28.51+00:00

I recently created policies to enforce the creation of certain tags on new Azure resources. Now when I try to enable auto-shutdown on an existing VM that is otherwise compliant with the tag policy I get an error:

 Schedule failed to update {"error":{"code":"RequestDisallowedByPolicy","target":"shutdown-computevm-","message":"Resource 'shutdown-computevm-' was disallowed by policy. 

Is there a way to exclude auto shutdown from the tag policy?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,201 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
799 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Pranathi Panyam_MSFT 1,006 Reputation points Microsoft Employee
    2023-09-21T04:16:09.48+00:00

    Hello @Elliott Kurtz

    Welcome to Microsoft Q&A, Thank you for posting your query here!!

    Yes, you can exclude certain resource types or specific resources from Azure Policy enforcement. Policy exemptions allow you to create exceptions for specific resources or resource types, allowing them to bypass the policy enforcement.

    Please refer to the document which has CLI commands, to create a policy exemption for your existing VM to exclude it from the tag policy enforcement and enable auto-shutdown.

    https://learn.microsoft.com/en-us/cli/azure/policy/exemption?view=azure-cli-latest

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.