Code to execute run commands on Azure VMs and VMSS using python sdks
- In Enterprises / Companies There will be multiple VMs or VMSS or both running
- These might be maintained and updated regularly or not
- Sometimes there will be a requirement to stop some services or so
- This can be used for the purpose
Inputs | Description | Required |
---|---|---|
subscription_name | Azure subscription name | ✔️ |
resource_group | Azure resource group name | ✔️ |
vm_name or vmss_name | Azure Vm or VMSS name | ✔️ |
- This program uses Azure Python SDKs to execute run commands
-
Clone this repo and change directory to
azure-runcommands-on-vm-vmss-with-python-sdk
-
Get the required parameters and run the code using below commands
-
python az_vm_runcommands.py --subscription_name
<Subscription Name>
--resource_group<resource group name>
--vm_name<VM name>
-
python az_vmss_runcommands.py --subscription_name
<Subscription Name>
--resource_group<resource group name>
--vmss_name<VMSS name>
-
azure-mgmt-resourcegraph This SDK is used to determine the subscription id from subscription name
-
azure-identity This is used for Authentication purposes
-
azure-mgmt-compute This package is used to execute the run commands on resources