Tidy up - Unused Project and Nuget package reference using Visual Studio 2019

If you are a Developer/Architect using Visual Studio as IDE for your development activities, this blog post will be of your interest. During the Ignite 2021 conference, Microsoft released Visual Studio 2019 v16.9 and v16.10 Preview 1. As part of version 16.10 Preview 1, one of the cool features they introduced is to "Remove Unused References..." for any Projects and Nuget packages that are not in use. At the time of writing this blog post, we have Visual Studio Version 16.10.0 (official release) which includes this new feature.  As part of development, we generally get carried away and introduce new Nuget package references to your project and add new references to your Projects. By the end of development, you will not be 100% sure which are not being referenced and unused which means you will leave those unused project references in your application. Now you might be wondering what's the big deal in it since it doesn't harm. The advantage of removing unused project r

How to Lock your Azure Resources?

Azure Resource Locking feature helps to prevent deletion and modification of Azure Resources on which the lock is been applied. Now you might be wondering how it's different and advantages compared to Azure RBAC (Role-Based Access Control)? RBAC is used as the first line of defense against restricting access to Azure Resources. Using RBAC you can restrict access to resources and resource actions. RBAC alone will not be sufficient across all environments especially from the Test environment onwards. RBAC and Resource lock doesn't conflict with each other rather they complement and should be applied as standard practice/pattern across all your Azure Subscriptions in your organization. 

Assume you are an Administrator, which means you have full access to all your resources. With Resource Lock applying it provides a way for administrators to lock down Azure resources to prevent deletion and modification of a resource. Resource lock applies to all users regardless of their roles.

There are 2 types of Resource Locks:

  1. CanNotDelete - It allows the resource to be modified however not deleted.
  2. ReadOnly - the resource can neither be deleted nor modified. Applying this lock is similar to restricting all authorized users to the permissions granted by the Reader role.
Note: Once a resource has been locked, the resource lock must first be removed before the resource can be modified or deleted. If the lock is applied at the parent level it inherits to child level resources and inheritance takes precedence.

Pre-Requisites:

For creating or deleting Resource locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only the Owner and User Access Administrator are granted those actions.

Applying Resource Lock using Azure Portal

  1. Navigate to the resource/ resource group/ subscription you wish to lock in the Azure Portal
  2. In the main blade select the "Locks" icon 
    Lock Option
                              
  3. Provide lock name and description and select the lock type as Delete or Read-only.
    Creating Lock

  4. Click OK to save the lock. The resource is now protected.
  5. In future if you want to change the lock type or delete the lock, navigate to "Resource" - "Locks"
    Option to Edit/Delete lock

Note: You can automate the process of applying Resource Lock using ARM template or Azure PowerShell or Azure CLI or Rest API.

Resource locks can be applied to subscriptions, resource groups, or individual resources. When you lock at the subscription level, all resources in that subscription including the ones added later will inherit the same lock. Considerations before applying locks can be found here

Reference:

Comments

Popular posts from this blog

Tidy up - Unused Project and Nuget package reference using Visual Studio 2019

Swagger UI for Azure Function v2 & v3 APIs

Authenticate Azure Functions - API Keys