Azure Functions Extensions Http FastApi library for Python
This library contains HttpV2 extensions for FastApi Request/Response types to use in your function app code.
Source code | Package (PyPi) | Developer Reference | Samples
Getting started
Prerequisites
- Python 3.8 or later is required to use this package. For more details, please read our page on Python Functions version support policy.
Instructions
- Follow the guide to create an app. If you're testing the function locally, make sure to update to the latest version of Core Tools.
- Ensure your app is using programming model v2 and contains an HttpTrigger function.
- Add
azurefunctions-extensions-http-fastapito your requirements.txt - Import Request and different types of responses from
azurefunctions.extensions.http.fastapiin your HttpTrigger functions. - Change the request and response types to ones imported from
azurefunctions.extensions.http.fastapi. - Add
"PYTHON_ENABLE_INIT_INDEXING": "1"to your local.settings.json file or App Settings. - Run your function app and try it out!
Bind to the FastApi type
The Azure Functions Extensions HTTP FastApi library for Python allows you to create a function app with FastApi Request or Response types. When your function runs, you will receive the FastApi Request type, and you can return a FastApi Response type.
FastApi is one of the top Python web frameworks that provides elegant and powerful Request/Response types and functionalities. With this integration, you are empowered to use Request/Response types the same way as with native FastApi. For example, HTTP streaming upload and download scenarios are now possible! Please reference the FastApi documentation for further information.
# This function app receives streaming data from a client and processes it in real-time.
# It demonstrates streaming upload capabilities for scenarios such as uploading large files,
# processing continuous data streams, or handling IoT device data.
import azure.functions as func
from azurefunctions.extensions.http.fastapi import Request, JSONResponse
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.route(route="streaming_upload", methods=[func.HttpMethod.POST])
async def streaming_upload(req: Request) -> JSONResponse:
"""Handle streaming upload requests."""
# Process each chunk of data as it arrives
async for chunk in req.stream():
process_data_chunk(chunk)
# Once all data is received, return a JSON response indicating successful processing
return JSONResponse({"status": "Data uploaded and processed successfully"})
def process_data_chunk(chunk: bytes):
"""Process each data chunk."""
# Add custom processing logic here
pass
Next steps
More sample code
Get started with our FastApi samples.
Several samples are available in this GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with FastApi:
-
fastapi_samples_streaming_upload - An example on how to send and receive a streaming request within your function.
-
fastapi_samples_streaming_download - An example on how to send your HTTP response via streaming to the caller.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Metadata
Release files for azurefunctions-extensions-http-fastapi 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| azurefunctions_extensions_http_fastapi-1.0.1.tar.gz | 9.1 kB | Without provenance | Details for azurefunctions_extensions_http_fastapi-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| azurefunctions_extensions_http_fastapi-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for azurefunctions_extensions_http_fastapi-1.0.1-py3-none-any.whl |
Total release size: 17.1 kB
Release files / azurefunctions_extensions_http_fastapi-1.0.1.tar.gz
| Download URL | azurefunctions_extensions_http_fastapi-1.0.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfbc1dbaf9bf31b7ec6b7e1f2aaf66f4b9b7c5368e658337938a4f700761add2
|
|
BLAKE2b-256 checksum How to use checksums |
ca86dd7e56db9973227f589a2e58d364bfebcfb6807ca1c27bd7125777cb5673
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / azurefunctions_extensions_http_fastapi-1.0.1-py3-none-any.whl
| Download URL | azurefunctions_extensions_http_fastapi-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3bbd7027204cd52a7f7271e51bcb24fbda7c75678bb6cf6ebe80b48d4726cfb
|
|
BLAKE2b-256 checksum How to use checksums |
9bda10c27a23e1bf8667ed094ca58c7b4b9f4ddf833ab02cd505a68bdbc51b01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for azurefunctions-extensions-http-fastapi 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.