Azure Resource Lock through policy but delete through DevOps

676 Views Asked by At

In this link a policy to lock resource group is given. Once it is implemented I would like the Devops pipeline to delete resources(as part of re-creation). I do not want the policy to prevent me from doing this(or temporarily allow me). How can I do it? As soon as the devops is done, Policy should act on this newly created object to lock it again.

1

There are 1 best solutions below

1
Shiraz Bhaiji On

Assuming that you have used 'deployIfNotExists', if you remove the lock the policy will put the lock on again.

Therefore the devops pipline must:

  • Disable the policy
  • Remove the lock from the resources that need to be recreated
  • Recreate the resource
  • Enable the policy