Skip to content

Shutdown VMs

Shutdown VMs #1291

Workflow file for this run

name: Shutdown VMs
on:
schedule:
- cron: "0 23 * * *"
defaults:
run:
shell: bash
jobs:
shutdown_vms:
name: Shutdown all virtual machines
runs-on: ubuntu-latest
steps:
- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Shutdown all virtual machines
run: |
set -e
VIRTUAL_MACHINES=$(az vm list --query "[].id" --output tsv)
for VIRTUAL_MACHINE in "${VIRTUAL_MACHINES}"; do
az vm stop --ids "${VIRTUAL_MACHINE}"
az vm deallocate --ids "${VIRTUAL_MACHINE}"
done