You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example demonstrates how to write out to a Service Bus queue in Python.
236
+
The following example demonstrates how to write out to a Service Bus queue in Python. The example depends on whether you use the [v1 or v2 Python programming model](functions-reference-python.md).
The following example demonstrates how to read a Service Bus queue message via a trigger.
209
+
The following example demonstrates how to read a Service Bus queue message via a trigger. The example depends on whether you use the [v1 or v2 Python programming model](functions-reference-python.md).
@@ -21,6 +21,23 @@ For information on how to manually run a timer-triggered function, see [Manually
21
21
22
22
Source code for the timer extension package is in the [azure-webjobs-sdk-extensions](https://github.com/Azure/azure-webjobs-sdk-extensions/blob/master/src/WebJobs.Extensions/Extensions/Timers/) GitHub repository.
23
23
24
+
::: zone pivot="programming-language-python"
25
+
Azure Functions supports two programming models for Python. The way that you define your bindings depends on your chosen programming model.
26
+
27
+
# [v2](#tab/python-v2)
28
+
The Python v2 programming model lets you define bindings using decorators directly in your Python function code. For more information, see the [Python developer guide](functions-reference-python.md?pivots=python-mode-decorators#programming-model).
29
+
30
+
# [v1](#tab/python-v1)
31
+
The Python v1 programming model requires you to define bindings in a separate *function.json* file in the function folder. For more information, see the [Python developer guide](functions-reference-python.md?pivots=python-mode-configuration#programming-model).
32
+
33
+
---
34
+
35
+
This article supports both programming models.
36
+
37
+
> [!IMPORTANT]
38
+
> The Python v2 programming model is currently in preview.
39
+
::: zone-end
40
+
24
41
## Example
25
42
26
43
::: zone pivot="programming-language-csharp"
@@ -95,7 +112,27 @@ public void keepAlive(
95
112
::: zone-end
96
113
::: zone pivot="programming-language-javascript,programming-language-python,programming-language-powershell"
97
114
98
-
The following example shows a timer trigger binding in a *function.json* file and function code that uses the binding, where an instance representing the timer is passed to the function. The function writes a log indicating whether this function invocation is due to a missed schedule occurrence.
115
+
The following example shows a timer trigger binding and function code that uses the binding, where an instance representing the timer is passed to the function. The function writes a log indicating whether this function invocation is due to a missed schedule occurrence. The example depends on whether you use the [v1 or v2 Python programming model](functions-reference-python.md).
@@ -208,6 +247,24 @@ The following table explains the binding configuration properties for C# script
208
247
---
209
248
210
249
::: zone-end
250
+
251
+
::: zone pivot="programming-language-python"
252
+
## Decorators
253
+
254
+
_Applies only to the Python v2 programming model._
255
+
256
+
For Python v2 functions defined using a decorator, the following properties on the `schedule`:
257
+
258
+
| Property | Description |
259
+
|-------------|-----------------------------|
260
+
|`arg_name`| The name of the variable that represents the timer object in function code. |
261
+
|`schedule`| A [CRON expression](#ncrontab-expressions) or a [TimeSpan](#timespan) value. A `TimeSpan` can be used only for a function app that runs on an App Service Plan. You can put the schedule expression in an app setting and set this property to the app setting name wrapped in **%** signs, as in this example: "%ScheduleAppSetting%". |
262
+
|`run_on_startup`| If `true`, the function is invoked when the runtime starts. For example, the runtime starts when the function app wakes up after going idle due to inactivity. when the function app restarts due to function changes, and when the function app scales out. *Use with caution.***runOnStartup** should rarely if ever be set to `true`, especially in production. |
263
+
|`use_monitor`| Set to `true` or `false` to indicate whether the schedule should be monitored. Schedule monitoring persists schedule occurrences to aid in ensuring the schedule is maintained correctly even when function app instances restart. If not set explicitly, the default is `true` for schedules that have a recurrence interval greater than or equal to 1 minute. For schedules that trigger more than once per minute, the default is `false`. |
264
+
265
+
For Python functions defined by using *function.json*, see the [Configuration](#configuration) section.
266
+
::: zone-end
267
+
211
268
::: zone pivot="programming-language-java"
212
269
## Annotations
213
270
@@ -221,6 +278,14 @@ The `@TimerTrigger` annotation on the function defines the `schedule` using the
221
278
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python"
222
279
223
280
## Configuration
281
+
::: zone-end
282
+
283
+
::: zone pivot="programming-language-python"
284
+
_Applies only to the Python v1 programming model._
285
+
286
+
::: zone-end
287
+
::: zone pivot="programming-language-javascript,programming-language-powershell,programming-language-python"
288
+
224
289
225
290
The following table explains the binding configuration properties that you set in the *function.json* file.
0 commit comments