Deploying a console app to the filesystem on an Azure VM using Azure Devops

Viewed 1717

I have a console application written in .Net core that functions as a windows service. My aim is to deploy this to one of our VMs using Azure devops so that we can install the application as a service and have it poll an internal api and run some business logic on a timer behind the scenes.

My build pipeline is in place in DevOps and is generating the necessary artifacts (basically the folder I want to deploy to the VM) as a zip file but the issue I am now having is deploying to the filesystem.

Usually in Devops we would be deploying to IIS using a service principle or an app service that is connected to our Azure tenant meaning a lot of the verification etc is done for us however, after trawling the Microsoft documentation I could not find an example of how to use a service principle (essentially a verified connection between DevOps and the VM) to deploy to the filesystem of the VM.

Does anyone have any pointers as to which task to use for this? I'm look at the transfer files via SSH option and it appears to allow you select a service principle (which we have in place anyway as we are already deploying IIS websites to this server) so in theory I believe I could use this.

Any help or pointers / best practise for this scenario would be greatly appreciated.

2 Answers

For this requirement, you can't use service principle, because the VM requires an account to authentication. For example, for Azure File Copy task, you still need to specify the user name and password.

I'd suggest that you could do it through deployment group.

  1. Create a new deployment group
  2. Register deployment agents to that deployment group on these Azure VMs.
  3. Edit pipeline and add deployment job with previous deployment group.
  4. Then all related artifacts could be download to that Azure VM and you could add additional tasks to do something else.

My build pipeline is generating the necessary artifacts as a zip file but the issue I am now having is deploying to the filesystem.

For this issue , you can first try to use the Azure File Copy task to copy the zip file to azure VM.

When the target is Azure VMs, the files are first copied to an automatically generated Azure blob container and then downloaded into the VMs. The container is deleted after the files have been successfully copied to the VMs.

Then you can use PowerShell on Target Machines task and write simple inline script to unzip the zip file and then run the .exe file. In addition, you need to configure remote configuration on the VM. This article may help you with this.

Related