Of course you need to be logged in, see answer. You can then invoke like this: from azhelper import * It requires you to have azure-cli installed for Python: pip install azure-cliįile azhelper.py: from import get_default_cliĬode = get_default_cli().invoke(args, None, temp) It uses a temporary file as output target and then it is read back in memory - this is required afaik from the underlying Knack CLI code by default StdOut is the standard pipe. ![]() I wrote a little helper function that accepts the Azure CLI instructions in one string (I don't like many arguments as list, it doesn't read nicely - but that is just a personal preference, don't blame me). in your terminal but you always get a zero for success. By default, this redirects to StdOut, that is why you can see it e.g. To get the full body response, you must pass a file like object on the argument list of the underlying Knack Code to get the response. ![]() invoke() instruction is always returning the error code. To use "cmd -c" would be a Windows-specific solution and needs a fork if/else for additional Linux answer is almost correct, as you can reuse the Azure CLI python modules, as the CLI is also written in Python. Using the subprocess solution is problematic as subprocess doesn't check the PATH where Azure CLI is found e.g.
0 Comments
Leave a Reply. |