Microsoft Server 2022 Azure VM In-Place Upgrade Automation
Updated: Jan 24, 2022
Overview:
This will be a three-part series covering the following topics:
Managed Identities - AAD Login for Windows Server Extension & Access Control
Azure Active Directory (AAD) Joined Server Remote Access Guide

Turn off any alerting for the server, e.g., Datadog, Newrelic, etc.!
Part 1: Microsoft Server 2022 Azure VM In-Place Upgrade
First, let's make sure your requirements align with what this guide will cover:
You have an Azure Server 2016/2019 VM that you wish to upgrade to Server 2022
You wish to safely perform the in-place upgrade by first taking an OS drive snapshot
You wish to streamline this process as much as possible
Prerequisites
To perform an in-place upgrade, we must meet the following requirements on the server:
Copy the Microsoft Server 2022 ISO file to an Azure storage account with a file share and create a shared access signature
The server is running .Net Framework 4.7.2
Enable Scripting - Active scripting for Javascript in Internet Explorer
Copy over our custom in-place upgrade script
Copy the Microsoft Server 2022 ISO file to an Azure storage account with a file share and create a shared access signature
You can access Azure storage accounts via Azure Storage Explorer or the Azure Portal.
Make sure your storage account is routable to the VMs that will receive the in-place upgrade.
The storage account needs an active file share directory
Create a new shared access signature (I placed a checkmark for all services/resource types/ and permissions. Set an expiry date/time.
The server is running .Net Framework 4.7.2
The Az modules in our script require the server to be running .Net Framework 4.7.2 or greater. Install this on the server prior to running the custom script in step 4. You will likely have to reboot the server after installation.
Enable Scripting - Active scripting for Javascript in Internet Explorer
The custom in-place upgrade script will prompt for your Azure Administrator credentials. This prompt will pass through Internet Explorer using Javascript. We must enable Active scripting to allow this window to generate properly.
To allow all websites within the Internet zone to run scripts within Internet Explorer:
1. On the web browser menu, click Tools or the "Tools" icon (which looks like a gear) and select Internet Options.

2. When the "Internet Options" window opens, select the Security tab.
3. On the "Security" tab, ensure the Internet zone is selected, and then click on the "Custom level..." button.

4. In the Security Settings – Internet Zone dialog box, click Enable for Active Scripting in the Scripting section.

5. When the "Warning!" window opens and asks, "Are you sure you want to change the settings for this zone?" select Yes.
6. Click OK at the bottom of the Internet Options window to close the dialog.
Copy over our custom in-place upgrade script
You can download/copy the custom script from GeekByte Github.
The script does the following:
Elevates as Administrator
Switches to TLS 1.2
Installs Az Modules and prerequisites
Asks for user inputs:
Subscription
Resource Group
Location
(Computer name is auto-extracted)
Takes a snapshot of the Operating System (OS) drive and saves it to the same resource group the server resides
Creates a new folder C:\Server2022-InPlaceUpgrade
Installs AzCopy
Downloads Server 2022 locally to the folder created above
Mounts the Server 2022 ISO and begins an in-place upgrade to Server 2022 Datacenter with Desktop Experience
Copy this script anywhere on the server that will receive the in-place upgrade.
Install the custom in-place upgrade script
Modify line 203 to include your Azure storage account information
Right-click on the script and run with Powershell
The script will ask for user inputs to identify the server being upgraded
Monitor the installation/reboot and verify the appropriate services and applications are functioning as per normal
Clean-Up
Once you verify the server is healthy, and its services are not disrupted, you can begin the cleanup phase.
Disable Scripting - Active scripting for Javascript in Internet Explorer
Delete the C:\Server2022-InPlaceUpgrade folder and it’s contents
(Only perform this once you verify the server is functioning as per normal. You can even delay this step as long as you set a reminder) Navigate to the RG of the upgraded server and delete the snapshot; it will have the server name followed by a timestamp:

You have successfully executed an in-place upgrade to Server 2022 on your Azure VM. You can now move on to Part 2: Managed Identities - AAD Login for Windows Server Extension & Access Control.
Feel free to comment below with any questions or comments.
If you found this article informative, please support my efforts by donating to my Ethereum ENS address: geekbyte.eth