sorry for this basic question but I would like some help from you expert as I am still learning fastaapi.
I have a simple testing application running python FastApi and trying to use it with azure cli.
what I am trying to do, is to have a get request using fastapi to list all the resource groups I have in my subscriptions.
Now, reading documentation and some forums, I have this code here:
@app.get("/azure")
def az_cli (args_str):
temp = tempfile.TemporaryFile()
args = args_str.split()
code = get_default_cli().invoke(['login', '--service-principal', '-u', '', '-p', '','--tenant',''])
resource = get_default_cli().invoke(args)
data = temp.read().strip()
temp.close()
return [args, resource]
This def
authenticate the user with service principle, and invoke a az command args
.
If I run unicorn and head to docs
and in the args field I type resource list
the code work just fine, doesn't throw any error, but nothing shows in the request body. the full output though is visible in the terminal.
Can please somebody explain me how can I have the body output in the docs body?
Thank you very much for any help you can provide and I hope my example is clear enough, and if not please feel free to ask more informations.