In this exercise, you will:
- Create a resource.
- Apply a read-only resource lock.
- Apply a delete resource lock.
- Delete a resource lock.
Task 1: Create a resource
Before we can see a resource lock in action, let's create a resource first!
- In the Azure portal, select Create a resource.
- Under Categories, select Storage.
- Under Storage Account, select Create.
- On the Basics tab of the Create storage account page, leave the default option for everything except for these settings.
- Select Review + Create.
- Once validated, select Create.
- Wait for the notification that the account was successfully created. Time for a leg stretch!
- Select Go to resource.
Task 2: Apply a read-only resource lock
- Before we start - what impact do you think a read-only resource lock will have on the storage account? Give yourself a minute to recap what you've learned.
- Scroll down until you find the Settings section in the left hand navigation panel.
- Select Locks.
- Select + Add.
- Enter a Lock name.
- Make sure the Lock type is set to Read-only.
- Select OK.
Task 3: Add a container to the storage account
In this task, you'll add a container to the storage account to store blobs.
- Select Containers in the left hand navigation panel. You might need to scroll to find it!
- Select + Container.
3. Enter a container name and select Create.
4. You should get an error message: Failed to create storage container.
The error message lets you know that you couldn't create a storage container because a lock is in place. The read-only lock prevents any create or update actions on the storage account.
Task 4: Modify the resource lock
- Head back to Locks in your left hand navigation panel.
- Select the read-only resource lock you created.
- Change the Lock type to Delete and select OK.
4. Head back to the Containers page.
5. Select + Container again.
6. Enter a container name and select Create.
7. Voila! Your storage container should appear in your list of containers.
So now that we changed our resource lock to a Delete lock, you can create and update things in your storage account. Deleting the resource lock itself would have the same effect.
Task 5: Delete the storage account
- Select Overview at the left hand navigation panel. You might need to scroll up to find it!
- Select Delete.
3. You should get a notification that says you can't delete the resource because it has a delete lock.
Task 6: Delete the resource lock and storage account
In this final task, let's remove the resource lock and delete the storage account from your Azure account.
- Challenge yourself first! Do you think you can delete the lock and storage account without any guidance?
- Select Locks from the left hand navigation panel.
- Select Delete.
- Head back to the home page in your Azure portal.
- Select Storage accounts.
- Select the storage account you used for this exercise.
- Select Delete.
- Enter the name of the storage account, and select Delete.
9. Check that your storage account was deleted. Head back to the storage accounts page, and you should find that the storage account you've created is gone.
You've just configured, updated, and removed a resource lock on an Azure resource.
- Make sure you've removed the storage account so that you don't rack up any charges!