Let's say you have a windows virtual machine running and you need to add an extension or you want to download and execute scripts on your Windows virtual machine. There is an easy way to do this on your virtual machine. You can use a custom script extension tool to download and execute script extension on Azure. This can be used for deploying any custom configuration or any software installation on your Windows virtual machine.
These custom scripts are a set of instructions that gets executed and these files can be stored in an Azure storage account or you can host these files on Github. Microsoft Azure executes these scripts for 90 minutes so we can say that the maximum time duration given for the script is 90 minutes to execute. if the script doesn't finish executions in 90 minutes then that means a failed extension provision.
it is important to note that these scripts shouldn't have reboot commands because if the virtual machine rebooted during executions of the script then it will be a failed execution. The extension will not continue to run after the reboot takes place. So if you think you have this kind of requirement then it is not advisable to use custom script extension and use some other tools.
Benefits
- No need for RDP or SSH to machine to install the software.
- No need for RDP or SSH to execute custom scripts on virtual machines.
How to use Custom Script Extension
Go to Azure Portal and go to the virtual machine and select your Windows virtual machine. if you don't have a virtual machine then you can create the virtual machine. You can learn more here about how to create a virtual machine. I would like to suggest creating windows virtual machine to test it out.
So if I go to the Azure virtual machine and take the public IP address of the virtual machine and browse you will see nothing because IIS is not running so what we gonna do is we are going to install IIS on this virtual machine.

Now let us use custom script extensions to install the IIS service on this virtual machine. So we are going to create a PowerShell script file and here we are importing the model of server manager and adding the windows feature of the webserver on this virtual machine. This will allows us to install IIS on this virtual machine. Below are the commands we are going to use.
import-module servermanager
add-windowsfeature web-server -includeallsubfeature









Gurpreet AroraPosted Jun 30, 2021, 1:35 PM
Nice article