Convert .NET Timer Function to Python v2 Programming Model #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR converts the existing .NET 8 Azure Functions Timer sample to Python v2 with 100% functional equivalence, as requested in the issue.
Overview
The conversion maintains all key functionality while adopting the Python v2 programming model with decorators for a more intuitive and Pythonic development experience.
Key Changes
Function Implementation
timerFunction.cswithtimer_function.pyusing the@app.timer_triggerdecorator%TIMER_SCHEDULE%environment variable with NCRONTAB formatrun_on_startup=Trueequivalent to the originalRunOnStartup=truefor immediate execution during testingmytimer.past_dueequivalent tomyTimer.IsPastDuefor handling delayed executionsRuntime and Infrastructure
'dotnet-isolated'to'python'with version'3.11'in Bicep configurationazure.yamlto specify Python language and updated project metadatahost.jsonwith Python-specific settings and extension bundlesDevelopment Environment
.devcontainerconfiguration with Python extensions and Python 3.11 supportrequirements.txtwithazure-functions>=1.18.0local.settings.jsonto use Python runtimeDocumentation and Examples
Code Quality
datetime.datetime.now(datetime.timezone.utc)instead of deprecatedutcnow()for Python 3.12+ compatibilityFunctional Equivalence Maintained
The Python version preserves all original functionality:
azd upDeployment
The converted function maintains the same deployment patterns:
azd updeployment workflowVNET_ENABLEDenvironment variable)This conversion provides a direct Python equivalent of the .NET timer function sample while following Azure Functions Python v2 best practices.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.functions.azure.comfunc start --build-native-deps --verbose(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)https://api.github.com/repos/Azure-Samples/Azure-Samples%2Ffunctions-quickstart-dotnet-azd-timer/languages/home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.