Skip to main content

Az.Cli

PyPi Build Status master Build Status dev

Python azure.cli.core interface to execute az Azure CLI commands in python.

The method returns a named tuple AzResult = namedtuple('AzResult', ['exit_code', 'result_dict', 'log']). The error_code where 0 == success. A result_dict containing successfull return as a python dictionary. On failure (error_code > 0) a log message inside log as a string.

Usage

Install the package

pip install az.cli

Login using az login, see sign in using a service principal.

Under the hood the package uses the ~/.azure folder to persist and retrieve config.

Example

from az.cli import az

# AzResult = namedtuple('AzResult', ['exit_code', 'result_dict', 'log'])
exit_code, result_dict, logs = az("group show -n test")

# On 0 (SUCCESS) print result_dict, otherwise get info from `logs`
if exit_code == 0:
    print (result_dict)
else:
    print(logs)

Interactive

You can run the command interactively to traverse the dictionary. Navigate to src and run python3. Import the library from az.cli import az and run any command by executing the method az("<my command>") to invoke Azure CLI.

# cd src
# python3
from az.cli import az
# on Success, the `error_code` is 0 and the result_dict contains the output
az("group list") # list return tuple (exit_code, result_dict, log)
az("group list")[0] # 0
az("group list")[1] # print result_dict
az("group list")[1][0]['id'] # enumerate the id of the first element in dictionary

# On Error, the `error_code` will be != 1 and the log is present
az("group show -n does-not-exsist") # list return tuple (exit_code, result_dict, log)
az("group show -n does-not-exsist")[0] # 3
az("group show -n does-not-exsist")[2] # print the log

Build

Local Development

  • install python3
  • install REQUIREMENTS.txt using make init

I recommend to use Python3 virtual environments.

# sets up environment
make env
# installs requirements
make init

Docker

To build the image run the following in order.

# Runs docker build & create
make create

Run

After the container is build & created you can run the az.cli interactivly.

# Run docker run
make run

Known Bugs

Metadata

Release files for az.cli 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for az.cli 0.3
File Size Uploaded Provenance Actions
az.cli-0.3.tar.gz 3.8 kB Without provenance Details for az.cli-0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for az.cli 0.3
File Interpreter ABI Platform Actions
az.cli-0.3-py3-none-any.whl Python 3 none any Details for az.cli-0.3-py3-none-any.whl

Total release size: 9.0 kB

Release files / az.cli-0.3.tar.gz

Download URL az.cli-0.3.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4b10a204199dbcfbe8da4244d6d2dcb9ebb1118a9dca5f21d9c7ca3574c99a8c
BLAKE2b-256 checksum
How to use checksums
a8d147633a4ef25011f800b23646840221fce17d518b570eab517da685c43d0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / az.cli-0.3-py3-none-any.whl

Download URL az.cli-0.3-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5cea8a54c85125a3e6083f3a9467c78cbe2cd4d7f917f631e15a7cb966b369e
BLAKE2b-256 checksum
How to use checksums
bcb97839031a99a559f459d5b01d05683e296589affb75d78f5e73791d317a8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Security for az.cli 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page