0

I've currently got a VM (win os) running in Azure. The vm has a service running. I would like the devops pipelines to:

  • access the VM
  • stop the service
  • upload the new built service (built artifact)
  • start the updated service

rdp and ssh are disabled on the vm

The main problem is that I've no idea how to access/be in the VM from devops pipelines.

Was wondering if there is specific powershell package I can use or any simple solution?

There is another similar question that takes in consideration creating custom agents in Azure and connected to devops How to access Azure VM from AzureDevOps Pipelines? But I would like to use the default devops agent available

Carlo Luther
  • 2,402
  • 7
  • 46
  • 75

1 Answers1

0

Your pipeline can access the VM if you:

  1. Install the Azure Pipelines agent on the target VM (with the service you wish to update)
  2. Set a system environment variable with something that identifies the VM as a unique "target"
  3. In your pipeline pool specification, add a demands clause, and reference the name of the environment variable you created in 2

This basically sets things up so that the pipeline can ONLY run on the machine that has this service.

It can run any ordinary executable on the VM by way of a powershell or pwsh (Powershell 7) task.

What it can't do, out of the box, is run elevated commands, as it's an ordinary process - this is what you'd need in order to stop and start the service.

I'm not going to link it here, as I haven't tried it, can't speak to its safety or effectiveness, but there's a project on GitHub called AzureAdmin which claims to be able to do what you need - you log into the VM once and install AzureAdmin as a service on the box, and then at that point, your tasks are supposedly capable of running elevated commands.

Disclaimers: I haven't run this, and I'm not making an endorsement of leaving a DevOps agent running as an administrator (as there are security concerns that would need to be addressed).

WaitingForGuacamole
  • 3,744
  • 1
  • 8
  • 22