from subprocess import call
call(["az", "vm", "list", "-g", "rgName"])az login --service-principal -u http://sample-cli-login -p Test1234 --tenant 54826b22-38d6-4fb2-bad9-b7b93a3e9c5a
from azure.cli.core import get_default_cli
get_default_cli().invoke(['vm', 'list', '-g', 'groupname'])How to run Azure CLI commands using python? get_default_cli
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.compute import ComputeManagementClient
client = get_client_from_cli_profile(ComputeManagementClient)
conda create -n peak python=3.6
pip install azure-cli
How to save the output of Azure-cli commands in a variable
login_successfull = get_default_cli().invoke(['login',
'--tenant', tenant,
'--username', self.username,
'--password', self.password]) == 0
tenant = 'mytenant.onmicrosoft.com'
cmd = AzureCmd('login', 'mypassword')
cmd.login(tenant)
cmd.list_vm(tenant)az account list -o table
az account set $SUBSCRIPTION_ID
az keyvault list -o table
az keyvault network-rule list --name <kv name> -o table
az network ddos-protection list
az network nsg list -o table
az network nsg rule list --nsg-name <nsg-name> -g <RG>
az storage account list -o table
az storage account network-rule list --account-name <accountname>