Skip to content

start or stop azure virtual machine #8

start or stop azure virtual machine

start or stop azure virtual machine #8

name: start or stop azure virtual machine
on:
workflow_dispatch:
inputs:
action:
default: "stop"
required: true
type: choice
options:
- start
- stop
vm_name:
required: true
default: "devwithkrishna-vm"
type: string
resource_group:
required: true
default: "DEV-WITH-KRISHNA-VM-RG"
type: string
resource_provider_string:
required: true
default: "providers/Microsoft.Compute/virtualMachines"
type: string
jobs:
start-or-stop-azure-virtual-machine:
runs-on: ubuntu-latest
name: ${{ github.actor }} ${{ github.event.inputs.action }} ${{github.event.inputs.vm_name}} VM
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_SECRET: ${{ secrets.AZURE_SECRET }}
steps:
- name: echo inputs
run: |
echo " action ${{github.event.inputs.action}} vmname ${{github.event.inputs.vm_name}} "
- name: azure login
uses: azure/login@v1
with:
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
- name: az cli commands
uses: azure/CLI@v1
with:
azcliversion: 2.55.0
inlinescript: |
az account set -s ${{ secrets.AZURE_SUBSCRIPTION_ID }}
az account show -o json