Skip to content

Commit 6be9ca8

Browse files
authored
Merge pull request #224057 from itechedit/functions-bindings-error-pages
edit pass: functions-bindings-error-pages.md
2 parents 3ca3b9c + cc6d93d commit 6be9ca8

File tree

1 file changed

+58
-49
lines changed

1 file changed

+58
-49
lines changed

articles/azure-functions/functions-bindings-error-pages.md

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,78 @@
11
---
22
title: Azure Functions error handling and retry guidance
3-
description: Learn to handle errors and retry events in Azure Functions with links to specific binding errors, including information on retry policies.
4-
3+
description: Learn how to handle errors and retry events in Azure Functions, with links to specific binding errors, including information on retry policies.
54
ms.topic: conceptual
65
ms.date: 01/03/2023
76
zone_pivot_groups: programming-languages-set-functions-lang-workers
87
---
98

109
# Azure Functions error handling and retries
1110

12-
Handling errors in Azure Functions is important to avoid lost data, missed events, and to monitor the health of your application. It's also important to understand the retry behaviors of event-based triggers.
11+
Handling errors in Azure Functions is important to help you avoid lost data, avoid missed events, and monitor the health of your application. It's also an important way to help you understand the retry behaviors of event-based triggers.
1312

1413
This article describes general strategies for error handling and the available retry strategies.
1514

1615
> [!IMPORTANT]
17-
> The retry policy support in the runtime for triggers other than Timer, Kafka, and Event Hubs is being removed after this feature becomes generally available (GA). Preview retry policy support for all triggers other than Timer and Event Hubs will be removed in December 2022. For more information, see the [Retries section below](#retries).
16+
> We're removing retry policy support in the runtime for triggers other than Timer, Kafka, and Event Hubs after this feature becomes generally available (GA). Preview retry policy support for all triggers other than Timer and Event Hubs was removed in December 2022. For more information, see the [Retries](#retries) section.
1817
1918
## Handling errors
2019

21-
Errors raised in an Azure Functions can come from any of the following origins:
20+
Errors that occur in an Azure function can result from any of the following:
2221

23-
- Use of built-in Azure Functions [triggers and bindings](functions-triggers-bindings.md).
24-
- Calls to APIs of underlying Azure services.
25-
- Calls to REST endpoints.
26-
- Calls to client libraries, packages, or third-party APIs.
22+
- Use of built-in Azure Functions [triggers and bindings](functions-triggers-bindings.md)
23+
- Calls to APIs of underlying Azure services
24+
- Calls to REST endpoints
25+
- Calls to client libraries, packages, or third-party APIs
2726

28-
Good error handling practices are important to avoid loss of data or missed messages. This section describes some recommended error handling practices with links to more information.
27+
To avoid loss of data or missed messages, it's important to practice good error handling. This section describes some recommended error-handling practices and provides links to more information.
2928

3029
### Enable Application Insights
3130

32-
Azure Functions integrates with Application Insights to collect error data, performance data, and runtime logs. You should use Application Insights to discover and better understand errors occurring in your function executions. To learn more, see [Monitor Azure Functions](functions-monitoring.md).
31+
Azure Functions integrates with Application Insights to collect error data, performance data, and runtime logs. You should use Application Insights to discover and better understand errors that occur in your function executions. To learn more, see [Monitor Azure Functions](functions-monitoring.md).
3332

3433
### Use structured error handling
3534

3635
Capturing and logging errors is critical to monitoring the health of your application. The top-most level of any function code should include a try/catch block. In the catch block, you can capture and log errors. For information about what errors might be raised by bindings, see [Binding error codes](#binding-error-codes).
3736

3837
### Plan your retry strategy
3938

40-
Several Functions bindings extensions provide built-in support for retries. In addition, the runtime lets you define retry policies for Timer, Kafka, and Event Hubs triggered functions. To learn more, see [Retries](#retries). For triggers that don't provide retry behaviors, you may want to implement your own retry scheme.
39+
Several Functions bindings extensions provide built-in support for retries. In addition, the runtime lets you define retry policies for Timer, Kafka, and Event Hubs-triggered functions. To learn more, see [Retries](#retries). For triggers that don't provide retry behaviors, you might want to implement your own retry scheme.
4140

4241
### Design for idempotency
4342

44-
The occurrence of errors when processing data can be a problem for your functions, especially when processing messages. You need to consider what happens when the error occurs and how to avoid duplicate processing. To learn more, see [Designing Azure Functions for identical input](functions-idempotent.md).
43+
The occurrence of errors when you're processing data can be a problem for your functions, especially when you're processing messages. It's important to consider what happens when the error occurs and how to avoid duplicate processing. To learn more, see [Designing Azure Functions for identical input](functions-idempotent.md).
4544

4645
## Retries
4746

48-
There are two kinds of retries available for your functions: built-in retry behaviors of individual trigger extensions and retry policies. The following table indicates which triggers support retries and where the retry behavior is configured. It also links to more information about errors coming from the underlying services.
47+
There are two kinds of retries available for your functions:
48+
* Built-in retry behaviors of individual trigger extensions
49+
* Retry policies provided by the Functions runtime
50+
51+
The following table indicates which triggers support retries and where the retry behavior is configured. It also links to more information about errors that come from the underlying services.
4952

5053
| Trigger/binding | Retry source | Configuration |
5154
| ---- | ---- | ----- |
5255
| Azure Cosmos DB | [Retry policies](#retry-policies) | Function-level |
53-
| Blob Storage | [Binding extension](functions-bindings-storage-blob-trigger.md#poison-blobs) | [host.json](functions-bindings-storage-queue.md#host-json) |
54-
| Event Grid | [Binding extension](../event-grid/delivery-and-retry.md) | Event subscription |
55-
| Event Hubs | [Retry policies](#retry-policies) | Function-level |
56-
| Queue Storage | [Binding extension](functions-bindings-storage-queue-trigger.md#poison-messages) | [host.json](functions-bindings-storage-queue.md#host-json) |
56+
| Azure Blob Storage | [Binding extension](functions-bindings-storage-blob-trigger.md#poison-blobs) | [host.json](functions-bindings-storage-queue.md#host-json) |
57+
| Azure Event Grid | [Binding extension](../event-grid/delivery-and-retry.md) | Event subscription |
58+
| Azure Event Hubs | [Retry policies](#retry-policies) | Function-level |
59+
| Azure Queue Storage | [Binding extension](functions-bindings-storage-queue-trigger.md#poison-messages) | [host.json](functions-bindings-storage-queue.md#host-json) |
5760
| RabbitMQ | [Binding extension](functions-bindings-rabbitmq-trigger.md#dead-letter-queues) | [Dead letter queue](https://www.rabbitmq.com/dlx.html) |
58-
| Service Bus | [Binding extension](../service-bus-messaging/service-bus-dead-letter-queues.md) | [Dead letter queue](../service-bus-messaging/service-bus-dead-letter-queues.md#maximum-delivery-count) |
61+
| Azure Service Bus | [Binding extension](../service-bus-messaging/service-bus-dead-letter-queues.md) | [Dead letter queue](../service-bus-messaging/service-bus-dead-letter-queues.md#maximum-delivery-count) |
5962
|Timer | [Retry policies](#retry-policies) | Function-level |
6063
|Kafka | [Retry policies](#retry-policies) | Function-level |
6164

6265
### Retry policies
6366

64-
Starting with version 3.x of the Azure Functions runtime, you can define a retry policies for Timer, Kafka, and Event Hubs triggers that are enforced by the Functions runtime. The retry policy tells the runtime to rerun a failed execution until either successful completion occurs or the maximum number of retries is reached.
67+
Starting with version 3.x of the Azure Functions runtime, you can define retry policies for Timer, Kafka, and Event Hubs triggers that are enforced by the Functions runtime.
68+
69+
The retry policy tells the runtime to rerun a failed execution until either successful completion occurs or the maximum number of retries is reached.
6570

66-
A retry policy is evaluated when a Timer, Kafka, or Event Hubs triggered function raises an uncaught exception. As a best practice, you should catch all exceptions in your code and rethrow any errors that you want to result in a retry. Event Hubs checkpoints won't be written until the retry policy for the execution has completed. Because of this behavior, progress on the specific partition is paused until the current batch has completed.
71+
A retry policy is evaluated when a Timer, Kafka, or Event Hubs-triggered function raises an uncaught exception. As a best practice, you should catch all exceptions in your code and rethrow any errors that you want to result in a retry. Event Hubs checkpoints won't be written until the retry policy for the execution has finished. Because of this behavior, progress on the specific partition is paused until the current batch has finished.
6772

6873
#### Retry strategies
6974

70-
There are two retry strategies supported by policy that you can configure:
75+
You can configure two retry strategies that are supported by policy:
7176

7277
# [Fixed delay](#tab/fixed-delay)
7378

@@ -81,7 +86,11 @@ The first retry waits for the minimum delay. On subsequent retries, time is adde
8186

8287
#### Max retry counts
8388

84-
You can configure the maximum number of times function execution is retried before eventual failure. The current retry count is stored in memory of the instance. It's possible that an instance has a failure between retry attempts. When an instance fails during a retry policy, the retry count is lost. When there are instance failures, the Event Hubs trigger is able to resume processing and retry the batch on a new instance, with the retry count reset to zero. Timer trigger doesn't resume on a new instance. This behavior means that the max retry count is a best effort, and in some rare cases an execution could be retried more than the maximum. For Timer triggers, the retries can be less than the maximum requested.
89+
You can configure the maximum number of times that a function execution is retried before eventual failure. The current retry count is stored in memory of the instance.
90+
91+
It's possible for an instance to have a failure between retry attempts. When an instance fails during a retry policy, the retry count is lost. When there are instance failures, the Event Hubs trigger is able to resume processing and retry the batch on a new instance, with the retry count reset to zero. The timer trigger doesn't resume on a new instance.
92+
93+
This behavior means that the maximum retry count is a best effort. In some rare cases, an execution could be retried more than the requested maximum number of times. For Timer triggers, the retries can be less than the maximum number requested.
8594

8695
#### Retry examples
8796

@@ -103,13 +112,13 @@ public static async Task Run([EventHubTrigger("myHub", Connection = "EventHubCon
103112
|Property | Description |
104113
|---------|-------------|
105114
|MaxRetryCount|Required. The maximum number of retries allowed per function execution. `-1` means to retry indefinitely.|
106-
|DelayInterval|The delay that is used between retries. Specify as a string with the format `HH:mm:ss`.|
115+
|DelayInterval|The delay that's used between retries. Specify it as a string with the format `HH:mm:ss`.|
107116

108117
# [Isolated process](#tab/isolated-process/fixed-delay)
109118

110-
Retry policies aren't yet supported when running in an isolated worker process.
119+
Retry policies aren't yet supported when they're running in an isolated worker process.
111120

112-
# [C# Script](#tab/csharp-script/fixed-delay)
121+
# [C# script](#tab/csharp-script/fixed-delay)
113122

114123
Here's the retry policy in the *function.json* file:
115124

@@ -129,11 +138,11 @@ Here's the retry policy in the *function.json* file:
129138
}
130139
```
131140

132-
|function.json property | Description |
141+
|*function.json* property | Description |
133142
|---------|-------------|
134143
|strategy|Use `fixedDelay`.|
135144
|maxRetryCount|Required. The maximum number of retries allowed per function execution. `-1` means to retry indefinitely.|
136-
|delayInterval|The delay that is used between retries. Specify as a string with the format `HH:mm:ss`.|
145+
|delayInterval|The delay that's used between retries. Specify it as a string with the format `HH:mm:ss`.|
137146

138147
# [In-process](#tab/in-process/exponential-backoff)
139148

@@ -151,14 +160,14 @@ public static async Task Run([EventHubTrigger("myHub", Connection = "EventHubCon
151160
|Property | Description |
152161
|---------|-------------|
153162
|MaxRetryCount|Required. The maximum number of retries allowed per function execution. `-1` means to retry indefinitely.|
154-
|MinimumInterval|The minimum retry delay. Specify as a string with the format `HH:mm:ss`.|
155-
|MaximumInterval|The maximum retry delay. Specify as a string with the format `HH:mm:ss`.|
163+
|MinimumInterval|The minimum retry delay. Specify it as a string with the format `HH:mm:ss`.|
164+
|MaximumInterval|The maximum retry delay. Specify it as a string with the format `HH:mm:ss`.|
156165

157166
# [Isolated process](#tab/isolated-process/exponential-backoff)
158167

159-
Retry policies aren't yet supported when running in an isolated worker process.
168+
Retry policies aren't yet supported when they're running in an isolated worker process.
160169

161-
# [C# Script](#tab/csharp-script/exponential-backoff)
170+
# [C# script](#tab/csharp-script/exponential-backoff)
162171

163172
Here's the retry policy in the *function.json* file:
164173

@@ -179,12 +188,12 @@ Here's the retry policy in the *function.json* file:
179188
}
180189
```
181190

182-
|function.json property | Description |
191+
|*function.json* property | Description |
183192
|---------|-------------|
184193
|strategy|Use `exponentialBackoff`.|
185194
|maxRetryCount|Required. The maximum number of retries allowed per function execution. `-1` means to retry indefinitely.|
186-
|minimumInterval|The minimum retry delay. Specify as a string with the format `HH:mm:ss`.|
187-
|maximumInterval|The maximum retry delay. Specify as a string with the format `HH:mm:ss`.|
195+
|minimumInterval|The minimum retry delay. Specify it as a string with the format `HH:mm:ss`.|
196+
|maximumInterval|The maximum retry delay. Specify it as a string with the format `HH:mm:ss`.|
188197

189198
---
190199
::: zone-end
@@ -231,18 +240,18 @@ Here's the retry policy in the *function.json* file:
231240

232241
---
233242

234-
|function.json property | Description |
243+
|*function.json* property | Description |
235244
|---------|-------------|
236245
|strategy|Required. The retry strategy to use. Valid values are `fixedDelay` or `exponentialBackoff`.|
237246
|maxRetryCount|Required. The maximum number of retries allowed per function execution. `-1` means to retry indefinitely.|
238-
|delayInterval|The delay that is used between retries when using a `fixedDelay` strategy. Specify as a string with the format `HH:mm:ss`.|
239-
|minimumInterval|The minimum retry delay when using an `exponentialBackoff` strategy. Specify as a string with the format `HH:mm:ss`.|
240-
|maximumInterval|The maximum retry delay when using `exponentialBackoff` strategy. Specify as a string with the format `HH:mm:ss`.|
247+
|delayInterval|The delay that's used between retries when you're using a `fixedDelay` strategy. Specify it as a string with the format `HH:mm:ss`.|
248+
|minimumInterval|The minimum retry delay when you're using an `exponentialBackoff` strategy. Specify it as a string with the format `HH:mm:ss`.|
249+
|maximumInterval|The maximum retry delay when you're using `exponentialBackoff` strategy. Specify it as a string with the format `HH:mm:ss`.|
241250

242251
::: zone-end
243252
::: zone pivot="programming-language-python"
244253

245-
Here's a Python sample to use retry context in a function:
254+
Here's a Python sample that uses the retry context in a function:
246255

247256
```Python
248257
import azure.functions
@@ -291,29 +300,29 @@ public void run(
291300
|Element | Description |
292301
|---------|-------------|
293302
|maxRetryCount|Required. The maximum number of retries allowed per function execution. `-1` means to retry indefinitely.|
294-
|delayInterval|The delay that is used between retries when using a `fixedDelay` strategy. Specify as a string with the format `HH:mm:ss`.|
295-
|minimumInterval|The minimum retry delay when using an `exponentialBackoff` strategy. Specify as a string with the format `HH:mm:ss`.|
296-
|maximumInterval|The maximum retry delay when using `exponentialBackoff` strategy. Specify as a string with the format `HH:mm:ss`.|
303+
|delayInterval|The delay that's used between retries when you're using a `fixedDelay` strategy. Specify it as a string with the format `HH:mm:ss`.|
304+
|minimumInterval|The minimum retry delay when you're using an `exponentialBackoff` strategy. Specify it as a string with the format `HH:mm:ss`.|
305+
|maximumInterval|The maximum retry delay when you're using `exponentialBackoff` strategy. Specify it as a string with the format `HH:mm:ss`.|
297306

298307
---
299308

300309
::: zone-end
301310

302311
## Binding error codes
303312

304-
When integrating with Azure services, errors may originate from the APIs of the underlying services. Information relating to binding-specific errors is available in the **Exceptions and return codes** section of the following articles:
313+
When you're integrating with Azure services, errors might originate from the APIs of the underlying services. Information that relates to binding-specific errors is available in the "Exceptions and return codes" sections of the following articles:
305314

306315
+ [Azure Cosmos DB](/rest/api/cosmos-db/http-status-codes-for-cosmosdb)
307-
+ [Blob storage](functions-bindings-storage-blob-output.md#exceptions-and-return-codes)
316+
+ [Blob Storage](functions-bindings-storage-blob-output.md#exceptions-and-return-codes)
308317
+ [Event Grid](../event-grid/troubleshoot-errors.md)
309318
+ [Event Hubs](functions-bindings-event-hubs-output.md#exceptions-and-return-codes)
310-
+ [IoT Hubs](functions-bindings-event-iot-output.md#exceptions-and-return-codes)
319+
+ [IoT Hub](functions-bindings-event-iot-output.md#exceptions-and-return-codes)
311320
+ [Notification Hubs](functions-bindings-notification-hubs.md#exceptions-and-return-codes)
312-
+ [Queue storage](functions-bindings-storage-queue-output.md#exceptions-and-return-codes)
321+
+ [Queue Storage](functions-bindings-storage-queue-output.md#exceptions-and-return-codes)
313322
+ [Service Bus](functions-bindings-service-bus-output.md#exceptions-and-return-codes)
314-
+ [Table storage](functions-bindings-storage-table-output.md#exceptions-and-return-codes)
323+
+ [Table Storage](functions-bindings-storage-table-output.md#exceptions-and-return-codes)
315324

316325
## Next steps
317326

318327
+ [Azure Functions triggers and bindings concepts](functions-triggers-bindings.md)
319-
+ [Best practices for reliable Azure Functions](functions-best-practices.md)
328+
+ [Best practices for reliable Azure functions](functions-best-practices.md)

0 commit comments

Comments
 (0)