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

Cleaning Azure Container Registry (ACR) on demand or schedule


In this blog post, we will see how to purge container images from Azure Container Registry (ACR). Till recent time most of them would have written custom PowerShell or bash script and run it to clean (purge) ACR container images. Recently Microsoft introduced a new preview feature to automatically purge images based on filters, duration, and untagged manifests. Additionally, this new preview feature supports to run on-demand or on a schedule using CRON expression.

In my current project, our delivery team is committing code several times a day. This automatically triggers a CI pipeline from which images are automatically built and pushed into ACR. Most of them would be going through the same journey. In this situation using this new preview feature, helps to keep ACR clean and not worrying about the Container registry getting bloated with images. 

Both on-demand or schedule will make use of acr purge command. ACR purge is designed to run as a container command in an ACR Task internally it authenticates automatically with the registry where the task runs and performs actions there. Purge command options and capabilities are defined here.

Note: Use the ACR purge command with caution--deleted image data is UNRECOVERABLE. 

On-Demand Task

On-demand task as the name says if you want to run on-demand or ad-hoc basis to purge container images based on the filter criteria defined.

On-Demand Task

Scheduled Task

Using the ACR purge command we can also schedule the purge to run automatically on a specific schedule. This is based on running ACR tasks. Schedule parameter in the below command is defined in Cron expressions format and you can read more about them at https://docs.microsoft.com/en-us/azure/container-registry/container-registry-tasks-scheduled#cron-expressions.
Scheduled Task 

View the list of Scheduled Task 

az acr task list -r <ACR Registry Name> -o table

List of Tasks

Delete the Scheduled Task

az acr task delete --name <Task Name> --registry <ACR Registry Name>

Delete Task


References:

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