Various Helper Tools to make working with azure functions easier
Project description
FuncTown
FuncTown
is a python library to make working with azure functions easier and remove boilerplate.
Getting Started
pip install functown
After installing you can easily get your functions error checked (with an auto-response for execptions triggered):
from functown import handle_errors
@handle_errors(debug=True)
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
# ...
return func.HttpResponse("success", status_code=200)
Should an exception happening in the middle, the decorator will auto-parse it (and write to logs if debug is true), then provide a response.
You can also parse JWT tokens and validate them (this currently requires to set the B2C_ISSUER_URL
and B2C_APP_ID
environment variables):
from functown.auth import verify_user
def main(req: func.HttpRequest) -> func.HttpResponse:
user, user_id, user_scp, local = verify_user(req, scope=scopes.SCOPE_WRITE)
Finally the library also allows you to easily parse arguments coming from the HttpRequest
:
from functown import RequestArgHandler
def main(req: func.HttpRequest) -> func.HttpResponse:
args = RequestArgHandler(req)
data = args.get_body_query("data_name", required=True, allowed=["foo", "bar"])
switch = args.get_body("bool_name", map_fct='bool')
file = args.get_file('file_name', required=True)
All this should remove boilerplate from Azure-Functions.
🎷 Welcome to FuncTown! 🎷
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file functown-0.1.4.tar.gz
.
File metadata
- Download URL: functown-0.1.4.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cad9fe8e0f707f76a50863dcc0e866241d4a13b3b3a2fdd78d634eb553aed0e2 |
|
MD5 | 92ae628f485fae1c87a9e9d18fc50eb2 |
|
BLAKE2b-256 | 0c0bcd034e16cabdbeae2c1b74e91bd589907d92b022771a22635df7fa050e1b |
File details
Details for the file functown-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: functown-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d60fb0af3849eebcadea825f6f9197254ac20908fecba6817650ab3eec338494 |
|
MD5 | 45e495bf647c4422d0fa4d086112b9e7 |
|
BLAKE2b-256 | a53a71d0946a02436525f9657327bd8a330ddfb65d001532a96f14fc5e53d392 |