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,983 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
912 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Pranathi Panyam_MSFT 1,046 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.


  2. Michał Zastocki 0 Reputation points
    2024-07-23T10:48:03.7866667+00:00

    The auto-shutdown function is actually a hidden resource located in the resource group. Its type is "microsoft.devtestlab/schedules".

    In my opinion, it would be best to exclude in the policy definition that requires tags for this type of resource (microsoft.devtestlab/schedules) instead of making an exception for the entire VM.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.