Skip to content

Instantly share code, notes, and snippets.

@bkrrajmali
Forked from geralexgr/start-vms-azure-pipeline
Created November 19, 2022 06:32
Show Gist options
  • Save bkrrajmali/975daa8dcdfa625dabc4797fbb726a80 to your computer and use it in GitHub Desktop.
Save bkrrajmali/975daa8dcdfa625dabc4797fbb726a80 to your computer and use it in GitHub Desktop.
trigger: none
pr: none
parameters:
- name: vms
type: object
default: ["ubuntu1","windows-1"]
pool:
vmImage: ubuntu-latest
jobs:
- job: startvmjob
displayName: Start VMs
steps:
- checkout: none
- ${{ each vm in parameters.vms }}:
- task: AzureCLI@2
displayName: starting vm ${{vm}}
inputs:
azureSubscription: 'Azure Subscription Service Connection'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
$vmrequest = az vm list | ConvertFrom-Json | Where-Object {$_.Name -Match "${{vm}}"}
az vm start --resource-group $vmrequest.resourcegroup --name $vmrequest.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment