How to deploy (additional) server roles on your IaaS Azure VM

Recently I needed an easy function to add additional servers roles on several IaaS virtual machines on a customer platform. This is how I accomplished this.

For this example I’m going to install the IIS server role, it works for other roles ofcourse. I’ve created an simple powershell script with the following content :

Install-WindowsFeature -name Web-Server -IncludeManagementTools

For this demo I named the .ps1 file InstallIIS.ps1

Using visual studio code I’ve specified my Azure subscription and invoke the powershell command :

Set-AzureRmContext -Subscription XX-XX-4693-bcad-ca3244783864
Invoke-AzureRmVMRunCommand `        
        -CommandId "RunPowerShellScript" `        
        -ResourceGroupName "my-resource-group" `       
        -VMName "demo-vm-001" `       
        -ScriptPath "C:\PS\InstallIIS.ps1"

After executing this command the IIS role will be installed on the demo-vm-001 server.

[do_widget id=hootkit-notice-3]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.