How to turn on azure machines using github actions?

I have three windows self-hosted runners for github actions.

Need to turn on the machines when the pipeline runs.

And want to turn off the machine once the pipeline finishes.

But, want to make sure, other pipelines are not running before turning off the machine.

Also, with azure, unlike aws, shuttting down the machine doesn’t stop the billing. So, we need to turnoff from azure portal/api. Thought to run that command at the end of pipeline but again, it needs another github runner(either self-hosted or provided by github actions) to do that step, if I do in the same runner, it won’t provide the return code correctly as the runner will be turned off.


I’m just launching self-hosted runner as the first job in my workflow, and killing it as the last job.
I’m using AWS, but the same should work in Azure, AFAIK.

1 Like

But I am using a windows machine(not windows container) and it is shared with multiple repositories.

Want to add a wait to check if any other pipelines are being running and turn it off after all ran.

Can you suggest how to do that?

1 Like

I see.

Want to add a wait to check if any other pipelines are being running and turn it off after all ran.
IMHO, it may be tricky to implement that.
I suggest launching a separate VM for each job and killing it at the end of the job. In this case, orchestration is simple.

1 Like

Kept a separate vm for building binaries.
But there is one stage at the end where we will create setup exe for the binaries created.
That step we need to do on a common machine, as applied single node locked license for installshield.

1 Like

I see. As far as there are no concurrent jobs, I’ll start this MS Win box on demand and shutdown it down after build is finished.

1 Like

Is there any option to check if any other jobs using this VM? And turn it down only if no jobs running

1 Like

Unfortunately, I don’t know. You can check Github workflow docs…
In fact, I’m not sure that github runner can execute a few jibs simultaneously. I suggest you to re-check in their docs, but AFAIK github runner has a single “executor” (in Jenkins’s slang).

1 Like

Thank you, Also one more query.

I have two workflows in my repo.
As they are independent, kept as two separate workflow files and everytime there is a commit, it starts both the workflows paralelly.

Is there anyway to set a setting that, one workflow should start first and 2nd workflow should wait until it completed?

1 Like

No. You can do that with jobs within one workflow, using needs.

1 Like