I assume the lock wins but I recommend devising a test to verify if needed.
What takes precedence - Azure Policy or Locks
I have a Resource Group named RG1. I have a Read-only Lock applied to RG1.
I have a Policy assigned to RG1 which has "allowed resource types" for "Virtual Machines".
Can I create a VM in RG1 ?
Azure Virtual Machines
Azure Policy
2 answers
Sort by: Most helpful
-
Andrew Blumhardt 10,051 Reputation points Microsoft Employee
2023-07-17T13:14:29.7133333+00:00 -
kobulloc-MSFT 26,811 Reputation points Microsoft Employee Moderator
2023-07-26T01:45:04.82+00:00 Hello, @Shridhar Srinivasan !
Can I deploy VMs into a resource group with a read only lock if there is a policy that has
allowed resource types
ofvirtual machines
?The short answer is "no", but this is because there isn't a policy that explicitly allows resource creation. Rather,
allowed resource types
works by denying resource types that are not explicitly listed as allowed resource types:When we look at the policy in more detail, we can see an if/then statement that matches the description of the policy:
Allowed Resource Type (Deny): Defines the resource types that you can deploy. Its effect is to deny all resources that aren't part of this defined list.
When testing this, we see that VM creation is not allowed in a read only resource group:
I hope this has been helpful! Your feedback is important so please take a moment to accept answers.
If you still have questions, please let us know what is needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!