This repository contains sample code for Python Azure Functions.
What is in the repository:
builderfunc
: this is just the boilerplate HTTP trigger in and HTTP response out for the Python Azure Functionfilereader
: this is a Python Azure Function with a Blob Trigger and a Event Hub output that can read blobs and send the content of the blobs as messages to the Event Hub
This function is currently built to parse PDFs and CSV documents.
- For PDFs, it uses the PyPDF2 library and it extracts the fields of the PDF and formats them as a JSON object.
- For CSVs it simply reads the blob into a Pandas DataFrame and then send back the first row as a comma-delimited string.
- Improved PDF parsing with Azure Cognitive Services for OCR and Computer Vision
- More file types for the purpose of having baseline examples for different types of files
- Install the Azure Functions Extension for VS Code
- Install the Core Tools For Azure Functions
- Establish your Virtual Environment for Python using
venv
by running the following:
Command Prompt
py -m venv .venv`
`.venv\scripts\activate
bash
python -m venv .venv
source .venv/bin/activate
- If you want to start the function: Go to the
__app__
directory and run:
func start
- Python Function Reference
- Good walkthrough for setting up a development environment for Python Functions
- Fantastic Python Function Samples
For Event Grid, the webhook should be formatted like: https://{name_of_function_app}.azurewebsites.net/runtime/webhooks/eventgrid?functionName={name_of_function}&{function_key}
If you ever need to publish from a different tenant than the one that loads as the default tenant when you login into to Azure from the Azure Functions Extention blade, do the following:
- Go to Visual Studio Code Settings
- Search "Azure"
- In the left hand bar menu choose "Configuration"
- Enter the tenant/directory ID that you want it to login into (see picture below):
- Log in and you should now be in that context