-
Notifications
You must be signed in to change notification settings - Fork 1
Port Azure Functions QuickStart from TypeScript to Python with v2 programming model #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ation Co-authored-by: nzthiago <[email protected]>
nzthiago
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of instantiating a python blob client using code, let's use the new SDK type bindings so that a ContainerClient as an Input binding, and use that client to upload the stream from the blob trigger. References:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=get-started%2Casgi%2Capplication-level&pivots=python-mode-decorators
https://techcommunity.microsoft.com/blog/azurecompute/azure-functions-sdk-type-bindings-for-azure-blob-storage-with-azure-functions-in/4146744
Samples! https://github.com/Azure-Samples/azure-functions-blob-sdk-bindings-python
nzthiago
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of instantiating a python blob client using code, let's use the new SDK type bindings so that a ContainerClient as an Input binding, and use that client to upload the stream from the blob trigger. References:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=get-started%2Casgi%2Capplication-level&pivots=python-mode-decorators
https://techcommunity.microsoft.com/blog/azurecompute/azure-functions-sdk-type-bindings-for-azure-blob-storage-with-azure-functions-in/4146744
Samples https://github.com/Azure-Samples/azure-functions-blob-sdk-bindings-python
Co-authored-by: nzthiago <[email protected]>
Implemented SDK type bindings as requested. The function now uses
Implemented SDK type bindings as requested. The function now uses |
nzthiago
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made some extra updates and tested locally and deployed. Please review the readme instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ports the Azure Functions Event Grid Blob Trigger sample from TypeScript to Python, implementing all required components for a complete Python-based Azure Functions solution using the v2 programming model.
- Complete Python function implementation with Event Grid blob trigger for near real-time PDF processing
- Infrastructure updates to support Python 3.12 runtime with Flex Consumption plan
- Comprehensive documentation and configuration updates for Python development environment
Reviewed Changes
Copilot reviewed 16 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/function_app.py | Main Python function implementation with Event Grid blob trigger and SDK-based blob operations |
| src/requirements.txt | Python dependencies for Azure Functions and blob storage extensions |
| src/host.json | Azure Functions host configuration with updated extension bundle |
| infra/main.bicep | Infrastructure template updated for Python runtime and maintained AVM modules |
| scripts/post-up.sh | Post-deployment script updated with Python function name reference |
| scripts/post-up.ps1 | PowerShell post-deployment script with Python function name reference |
| README.md | Comprehensive Python-specific setup and deployment documentation |
| azure.yaml | Project configuration updated for Python language |
Comments suppressed due to low confidence (1)
src/requirements.txt:5
- The package 'azurefunctions-extensions-bindings-blob' does not exist in the Python Package Index. For Python Azure Functions v2 programming model with blob bindings, you should use 'azure-storage-blob' and 'azure-identity' packages instead.
azurefunctions-extensions-bindings-blob>=1.1.0
| path="unprocessed-pdf/{name}", | ||
| connection="PDFProcessorSTORAGE", | ||
| source=func.BlobSource.EVENT_GRID) | ||
| @app.blob_input(arg_name="processed_container", |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @app.blob_input decorator with a container path will not return a ContainerClient object. This binding approach is incorrect for the Python v2 programming model. Use the azure-storage-blob SDK directly within the function instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct, you are likely working with older information.
|
@nzthiago Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
Reviewed and updated the README instructions to reflect the latest changes. Fixed outdated references to |
This PR ports the Azure Functions Event Grid Blob Trigger sample from TypeScript to Python, implementing all required components for a complete Python-based Azure Functions solution.
Overview
Successfully migrated the entire TypeScript Azure Functions sample to Python 3.12 using the Azure Functions Python v2 programming model. The sample demonstrates Event Grid blob triggers for near real-time PDF processing with secure managed identity authentication.
Key Changes
🐍 Python Function Implementation
src/function_app.py: Complete port of the blob processing logic using Python v2 programming modelazure-storage-blobandazure-identitypackages🏗️ Infrastructure Updates
infra/main.bicep: Updated runtime configuration fromnodetopythonwith version3.12⚙️ Configuration & Dependencies
src/requirements.txt: Python dependencies with latest Azure SDK versionssrc/host.json: Updated with latest extension bundles[4.*, 5.0.0)azure.yaml: Changed language setting fromjstopython📚 Documentation
Validation Results
✅ Python 3.12 Environment: Successfully tested with Python 3.12.3
✅ Function Registration: Confirmed 1 function properly registered with EventGrid trigger
✅ Azure SDK Dependencies: All packages install without conflicts
✅ Infrastructure Validation: Bicep files contain correct Python runtime references
✅ Script Updates: Post-deployment scripts properly reference
process_blob_uploadBenefits Maintained
Testing
The Python port has been validated for:
Ready for deployment with
azd up.Fixes #1.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.