|
1 | 1 | # azure-runcommands-on-vm-vmss-with-python-sdk
|
2 | 2 | Code to execute run commands on Azure VMs and VMSS using python sdks
|
3 | 3 |
|
| 4 | +# Why? |
4 | 5 |
|
5 |
| -https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-compute/32.0.0/azure.mgmt.compute.html#azure.mgmt.compute.ComputeManagementClient.virtual_machine_run_commands |
| 6 | +* In Enterprises / Companies There will be multiple VMs or VMSS or both running |
| 7 | +* These might be maintained and updated regularly or not |
| 8 | +* Sometimes there will be a requirement to stop some services or so |
| 9 | +* This can be used for the purpose |
6 | 10 |
|
| 11 | + |
| 12 | +# Inputs |
| 13 | + |
| 14 | +| Inputs | Description | Required | |
| 15 | +|--------|-------------|----------| |
| 16 | +| subscription_name | Azure subscription name | :heavy_check_mark: | |
| 17 | +| resource_group | Azure resource group name | :heavy_check_mark: | |
| 18 | +| vm_name or vmss_name | Azure Vm or VMSS name | :heavy_check_mark: | |
| 19 | + |
| 20 | + |
| 21 | +# How |
| 22 | + |
| 23 | +* This program uses Azure Python SDKs to execute run commands |
| 24 | + |
| 25 | + |
| 26 | +# How to run locally |
| 27 | + |
| 28 | +* Clone this repo and change directory to `azure-runcommands-on-vm-vmss-with-python-sdk` |
| 29 | + |
| 30 | +* Get the required parameters and run the code using below commands |
| 31 | + |
| 32 | +* python az_vm_runcommands.py --subscription_name `<Subscription Name>` --resource_group `<resource group name>` --vm_name `<VM name>` |
| 33 | + |
| 34 | +* python az_vmss_runcommands.py --subscription_name `<Subscription Name>` --resource_group `<resource group name>` --vmss_name `<VMSS name>` |
| 35 | + |
| 36 | + |
| 37 | +# References |
| 38 | + |
| 39 | +* [azure-mgmt-resourcegraph](https://learn.microsoft.com/en-us/python/api/overview/azure/mgmt-resourcegraph-readme?view=azure-python) |
| 40 | + This SDK is used to determine the subscription id from subscription name |
| 41 | + |
| 42 | +* [azure-identity](https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python) |
| 43 | + This is used for Authentication purposes |
| 44 | + |
| 45 | +* [azure-mgmt-compute](https://learn.microsoft.com/en-us/python/api/overview/azure/mgmt-compute-readme?view=azure-python) |
| 46 | + This package is used to execute the run commands on resources |
| 47 | +* [python/azure-mgmt-compute](https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-compute/32.0.0/azure.mgmt.compute.html#azure.mgmt.compute.ComputeManagementClient.virtual_machine_run_commands) |
0 commit comments