Run an Azure CLI command. Args: args (list[str]): The az CLI arguments (without the leading 'az'). capture (bool): Whether to capture stdout/stderr. Defaults to True. check (bool): Whether to raise on non-zero exit. Defaults to True. Returns: subprocess
(
*,
args: list[str],
capture: bool = True,
check: bool = True,
)
| 52 | |
| 53 | |
| 54 | def run_az( |
| 55 | *, |
| 56 | args: list[str], |
| 57 | capture: bool = True, |
| 58 | check: bool = True, |
| 59 | ) -> subprocess.CompletedProcess[str]: |
| 60 | """ |
| 61 | Run an Azure CLI command. |
| 62 | |
| 63 | Args: |
| 64 | args (list[str]): The az CLI arguments (without the leading 'az'). |
| 65 | capture (bool): Whether to capture stdout/stderr. Defaults to True. |
| 66 | check (bool): Whether to raise on non-zero exit. Defaults to True. |
| 67 | |
| 68 | Returns: |
| 69 | subprocess.CompletedProcess[str]: The completed process. |
| 70 | |
| 71 | Raises: |
| 72 | subprocess.CalledProcessError: If the command fails and check is True. |
| 73 | """ |
| 74 | cmd = ["az"] + args |
| 75 | logger.debug("Running: %s", " ".join(cmd)) |
| 76 | return subprocess.run( |
| 77 | cmd, |
| 78 | capture_output=capture, |
| 79 | text=True, |
| 80 | check=check, |
| 81 | shell=_SHELL, |
| 82 | ) |
| 83 | |
| 84 | |
| 85 | def run_az_json(*, args: list[str]) -> dict | list | str: |
no test coverage detected