Skip to content

jiasli/pyaz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyaz

A Python wrapper of Azure CLI. Happy scripting with Python!

Usage

Copy pyaz.py to your project and from pyaz import az.

Invocation

Simply call az("group show --name mygroup"). The output can be parsed as JSON:

from pyaz import az
import json

accounts = json.loads(az('account list').out)
print("My subscriptions:")
for a in accounts:
    selected = "*" if a["isDefault"] else " "
    print("{} {} {}".format(selected, a["id"], a["name"]))

Return value

The return value of az() is a named tuple:

Field Terminal Equivalent
exit_code $?(Bash), %ERRORLEVEL%(CMD), $LastExitCode(PowerShell)
out stdout
log stderr

Change logging level

To get the same log as --verbose or --debug, change pyaz.logging_level to logging.INFO or logging.DEBUG.

About

A Python wrapper of Azure CLI. Happy scripting with Python!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages