Category Archives: Technical

Azure VM run commands

Azure VM run commands is a mechanism to run a PowerShell script inside a VM which is hosted on Azure. I need to perform some steps inside a Azure VM as a part of CI CD but I can’t open a connection to the VM for security reasons. In this case I find the Azure VM run commands is very useful. I use this to run a PowerShell script from my CI CD agent to the Azure VM.

There are three ways with which you can run a script inside the VM from outside without connecting to the VM. First is from Azure Portal, second is with Azure CLI and third is with Azure PowerShell. In my case I used Azure PowerShell.

You need to create a PowerShell script (.ps1) file which you need to run inside the VM. Then you need to login to Azure with Connect-AzAccount and use Invoke-AzVMRunCommand to run the command inside the VM.

I have created a PowerShell script file with name HelloUser.ps1.

    [Parameter(Mandatory = $true)]

Write-Host "Hello $UserName"

Then I have logged in to Azure.


After login I can use Invoke-AzVMRunCommand to run HelloUser.ps1 script inside the VM.

Invoke-AzVMRunCommand `
    -ResourceGroupName "vm-resource-group" `
    -Name "target-vm-name" `
    -CommandId "RunPowerShellScript" `
    -ScriptPath "HelloUser.ps1" `
    -Parameter @{"UserName" = "Jon"}

Read more about Azure VM run commands here.

Why pull request

I often have been asked that why we need pull request.

If your workflow have pull request in it then it will help you to start a code changes and discuss the solution with your team members and eventually come up with a new feature in your application. It helps you to discuss code changes asynchronously with other person.

Particularly in the world of open source, pull request really shines. Any one can contribute in your codebase and they can be outside of your team, may be they are in a different time zone. In this case it is easy to open a pull request with a code change and work asynchronously with other members. GitHub has a very sophisticated code review process around pull request.

Overall it is the new way of workflow in a software project where you can collaborate with your team members or anyone who wants to contribute. Also you can propose code changes to other’s repositories and the owner of the repository can review your changes before merge through pull request.

If you attach issues with pull requests in GitHub then after marge in the future you can check the issue and able to find all the code changes related to that issue in the attached pull request.

IEnumerable Visualizer

I found a nice post on StackOverflow for exporting data from IEnumerable to CSV. You can able to find the post here.

Now Visual Studio 2022 has built in IEnumerable Visualizer in it.

Also it has a ‘Export to Excel’ button from where you can export the data to excel.