Setting a Resource Lock on Azure resources using PowerShell

Posted on Posted in Cloud, Scripts

This post shows you how to apply Locks to resources in Azure Resource Manager using PowerShell. Locks can be set for two things:

  • Accidental deletion
    Useful whe  somebody accidentally clicks on the Delete button or if someone is playing around with PowerShell and removes a Resource (Group).
  • Prevent changes
    This options prevents changes to a Resource which is useful if a (for example) production Resource should not change.

If you want to read more about Tags you can go to this website.

To use PowerShell with Azure, you will need the Azure PowerShell module which is explained here.

Here is the script to set the Accidental deletion lock on all your resources. You should add the name of your Subscription to the script.

Leave a Reply

Your email address will not be published. Required fields are marked *