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 enable Automatic Guest OS Patching for Windows Azure VMs?

For any organization and project security plays a very important role, towards that Microsoft tries to simplify and eases the effort required by the customer or end-user. One such thing that they recently announced is Automatic Guest OS patching for windows Azure VMs which is now public preview.

With Azure Automatic Guest OS patching enabled it helps update management by safely and automatically patching virtual machines to maintain security compliance. Here VMs are checked periodically for available operating system patches. Operating system patches classified as critical or security are automatically downloaded and applied on the VM. If VM is powered off during assessment by the platform for patching, VM will be automatically assessed during the next periodic assessment when it's turned on. Patches are applied within the 30 days of the monthly Windows update release. 

Automatic VM guest patching has the following capabilities:

  • Patches classified as Critical or Security is automatically downloaded and applied on the VM.
  • Patches are applied during off-peak hours in the VMs time zone. The VM must be running during off-peak hours for patches to be automatically installed.
  • Patches are applied based on availability-first principles.
  • Works for all VM sizes (No additional cost etc.)

Pre-Requisites

  • VM must have Azure VM Agent installed.
  • Supported OS - Windows Server 2012 R2, 2016, 2019. Custom images are currently not supported in the preview.
  • Windows update service must be running on VM.
  • Use Compute API version 2020-06-01 or higher.
  • The virtual machine must be able to access Windows Update endpoints.

Steps to enable Automatic Guest OS Patching

You can enable using Azure PowerShell or CLI 2.0 or Rest API. In this post, I will be showing using Azure CLI 2.0.

# Register az feature - Note: Feature registration can take up to 15 minutes
az feature register --namespace Microsoft.Compute --name InGuestAutoPatchVMPreview

# Check the registration status
az feature show --namespace Microsoft.Compute --name InGuestAutoPatchVMPreview

#Once the feature is registered for your subscription, complete the opt-in process by propagating the change into the Compute resource provider.
az provider register --namespace Microsoft.Compute

Once the above commands are executed you can enable automatic guest os patching for your existing Azure VMs use the following command.

az vm update --resource-group <myResourceGroup> --name <VM name> --set osProfile.windowsConfiguration.enableAutomaticUpdates=true osProfile.windowsConfiguration.patchSettings.patchMode=AutomaticByPlatform

Once enabled you can view the status or changes applied using the following command.

az vm get-instance-view --resource-group <myresourcegroup> --name <vm name>


Note: If the Automatic updates feature is not enabled on the flag then this Auto patching by platform can't be enabled.

In case if you want to trigger an on-demand patch assessment on your VM at any time use the below command. on-demand patch assessment doesn't automatically trigger it will still go through things like VMs off-peak hours and availability-first patching process.

Invoke-AzVmPatchAssessment -ResourceGroupName <myresourcegroup> -VMName <vm name>

Reference:

https://azure.microsoft.com/en-us/updates/automatic-vm-guest-patching-now-in-preview/

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