Skip to content

Commit 4b292b3

Browse files
authored
Add Function Execution Retry Support (#6706)
1 parent ab809da commit 4b292b3

File tree

21 files changed

+426
-32
lines changed

21 files changed

+426
-32
lines changed

WebJobs.Script.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,29 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HttpTrigger", "HttpTrigger"
320320
sample\CustomHandler\HttpTrigger\function.json = sample\CustomHandler\HttpTrigger\function.json
321321
EndProjectSection
322322
EndProject
323+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HttpTrigger-Retry", "HttpTrigger-Retry", "{821D5B92-2C3E-44F0-AA92-8B996DCB8E6C}"
324+
ProjectSection(SolutionItems) = preProject
325+
sample\Node\HttpTrigger-Retry\function.json = sample\Node\HttpTrigger-Retry\function.json
326+
sample\Node\HttpTrigger-Retry\index.js = sample\Node\HttpTrigger-Retry\index.js
327+
EndProjectSection
328+
EndProject
329+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NodeRetry", "NodeRetry", "{EEBAC197-FAD8-4214-9A12-76334BB3021A}"
330+
ProjectSection(SolutionItems) = preProject
331+
sample\NodeRetry\host.json = sample\NodeRetry\host.json
332+
EndProjectSection
333+
EndProject
334+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HttpTrigger-FunctionJsonRetry", "HttpTrigger-FunctionJsonRetry", "{7935A7A4-191A-4A9B-B8DD-173968309EBF}"
335+
ProjectSection(SolutionItems) = preProject
336+
sample\NodeRetry\HttpTrigger-RetryFunctionJson\function.json = sample\NodeRetry\HttpTrigger-RetryFunctionJson\function.json
337+
sample\NodeRetry\HttpTrigger-RetryFunctionJson\index.js = sample\NodeRetry\HttpTrigger-RetryFunctionJson\index.js
338+
EndProjectSection
339+
EndProject
340+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HttpTrigger-HostJsonRetry", "HttpTrigger-HostJsonRetry", "{CF6D9CDA-2290-46DF-B162-2D422477288A}"
341+
ProjectSection(SolutionItems) = preProject
342+
sample\NodeRetry\HttpTrigger-RetryHostJson\function.json = sample\NodeRetry\HttpTrigger-RetryHostJson\function.json
343+
sample\NodeRetry\HttpTrigger-RetryHostJson\index.js = sample\NodeRetry\HttpTrigger-RetryHostJson\index.js
344+
EndProjectSection
345+
EndProject
323346
Global
324347
GlobalSection(SharedMSBuildProjectFiles) = preSolution
325348
test\WebJobs.Script.Tests.Shared\WebJobs.Script.Tests.Shared.projitems*{35c9ccb7-d8b6-4161-bb0d-bcfa7c6dcffb}*SharedItemsImports = 13
@@ -414,6 +437,10 @@ Global
414437
{BA45A727-34B7-484F-9B93-B1755AF09A2A} = {0AE3CE25-4CD9-4769-AE58-399FC59CF70F}
415438
{A59D3F65-53E5-4666-AEFE-882987A39A49} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
416439
{209DC34B-762E-4B1B-B094-EBD7C4B972C2} = {A59D3F65-53E5-4666-AEFE-882987A39A49}
440+
{821D5B92-2C3E-44F0-AA92-8B996DCB8E6C} = {9D87C796-7914-4A43-B843-579562393E10}
441+
{EEBAC197-FAD8-4214-9A12-76334BB3021A} = {FF9C0818-30D3-437A-A62D-7A61CA44F459}
442+
{7935A7A4-191A-4A9B-B8DD-173968309EBF} = {EEBAC197-FAD8-4214-9A12-76334BB3021A}
443+
{CF6D9CDA-2290-46DF-B162-2D422477288A} = {EEBAC197-FAD8-4214-9A12-76334BB3021A}
417444
EndGlobalSection
418445
GlobalSection(ExtensibilityGlobals) = postSolution
419446
SolutionGuid = {85400884-5FFD-4C27-A571-58CB3C8CAAC5}

release_notes.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add a new host.json property "watchFiles" for restarting the Host when files are modified.
99
- Update Java Worker to 1.8.0 [Release Note](https://github.com/Azure/azure-functions-java-worker/releases/tag/1.8.0)
1010
- Update Java Library to 1.4.0 [Release Note](https://github.com/Azure/azure-functions-java-library)
11+
- Added support for function execution retry on invocation failures [#6664](https://github.com/Azure/azure-functions-host/issues/6664)
1112
- **[BreakingChange]** Fixes [#400](https://github.com/Azure/azure-functions-java-worker/issues/400) which was a regression from the 1.7.1 release.
1213
There is potential of impact if the function code has taken a dependency on a feature in gson 2.8.6 as the dependency `gson-2.8.5.jar` is now included in the class path of the worker and will take precedence over the function's lib folder.
1314
- **Breaking Changes in CustomHandler**
@@ -30,4 +31,7 @@
3031
If you are using these properties, please ensure your app is able to detect and handle the new schema.
3132

3233
**Release sprint:** Sprint 84
33-
[ [bugs](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+84%22+label%3Abug+is%3Aclosed) | [features](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+84%22+label%3Afeature+is%3Aclosed) ]
34+
[ [bugs](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+84%22+label%3Abug+is%3Aclosed) | [features](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+84%22+label%3Afeature+is%3Aclosed) ]
35+
36+
**Release sprint:** Sprint 85
37+
[ [bugs](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+85%22+label%3Abug+is%3Aclosed) | [features](https://github.com/Azure/azure-functions-host/issues?q=is%3Aissue+milestone%3A%22Functions+Sprint+85%22+label%3Afeature+is%3Aclosed) ]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"bindings": [
3+
{
4+
"type": "httpTrigger",
5+
"direction": "in",
6+
"name": "req",
7+
"methods": [
8+
"get",
9+
"post"
10+
]
11+
},
12+
{
13+
"type": "http",
14+
"direction": "out",
15+
"name": "res"
16+
}
17+
],
18+
"retry": {
19+
"strategy": "fixedDelay",
20+
"maxRetryCount": 4,
21+
"delayInterval": "00:00:03"
22+
}
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var invocationCount = 0;
2+
3+
module.exports = async function (context, req) {
4+
const reset = req.query.reset;
5+
invocationCount = reset ? 0 : invocationCount
6+
7+
context.log('JavaScript HTTP trigger function processed a request.invocationCount: ' + invocationCount);
8+
9+
invocationCount = invocationCount + 1;
10+
const responseMessage = "invocationCount: " + invocationCount;
11+
if (invocationCount < 4) {
12+
throw new Error('An error occurred');
13+
}
14+
context.res = {
15+
// status: 200, /* Defaults to 200 */
16+
body: responseMessage
17+
};
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"bindings": [
3+
{
4+
"type": "httpTrigger",
5+
"direction": "in",
6+
"name": "req",
7+
"methods": [
8+
"get",
9+
"post"
10+
]
11+
},
12+
{
13+
"type": "http",
14+
"direction": "out",
15+
"name": "res"
16+
}
17+
]
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var invocationCount = 0;
2+
3+
module.exports = async function (context, req) {
4+
const reset = req.query.reset;
5+
invocationCount = reset ? 0 : invocationCount
6+
7+
context.log('JavaScript HTTP trigger function processed a request.invocationCount: ' + invocationCount);
8+
9+
invocationCount = invocationCount + 1;
10+
const responseMessage = "invocationCount: " + invocationCount;
11+
if (invocationCount < 2) {
12+
throw new Error('An error occurred');
13+
}
14+
context.res = {
15+
// status: 200, /* Defaults to 200 */
16+
body: responseMessage
17+
};
18+
}

sample/NodeRetry/host.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": "2.0",
3+
"retry": {
4+
"strategy": "fixedDelay",
5+
"maxRetryCount": 2,
6+
"delayInterval": "00:00:03"
7+
}
8+
}

src/WebJobs.Script.WebHost/WebJobs.Script.WebHost.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
<PackageReference Include="Microsoft.Azure.AppService.Proxy.Client" Version="2.0.8100001-0126c21e" />
6060
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
6161
<PackageReference Include="Microsoft.Azure.Storage.File" Version="11.1.7" />
62-
<PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="4.0.1" />
63-
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.22" />
62+
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.23-11785" />
63+
<PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="4.0.1" />
6464
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.3" />
6565
<PackageReference Include="Microsoft.Azure.WebJobs.Logging" Version="4.0.1" />
6666
<PackageReference Include="Microsoft.Azure.WebSites.DataProtection" Version="2.1.91-alpha" />

src/WebJobs.Script/Config/ConfigurationSectionNames.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ public static class ConfigurationSectionNames
2121
public const string Hsts = Http + ":hsts";
2222
public const string CustomHttpHeaders = Http + ":customHeaders";
2323
public const string EasyAuth = "easyauth";
24+
public const string Retry = "retry";
2425
}
2526
}

src/WebJobs.Script/Config/HostJsonFileConfigurationSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class HostJsonFileConfigurationProvider : ConfigurationProvider
4949
{
5050
private static readonly string[] WellKnownHostJsonProperties = new[]
5151
{
52-
"version", "functionTimeout", "functions", "http", "watchDirectories", "watchFiles", "queues", "serviceBus",
52+
"version", "functionTimeout", "retry", "functions", "http", "watchDirectories", "watchFiles", "queues", "serviceBus",
5353
"eventHub", "singleton", "logging", "aggregator", "healthMonitor", "extensionBundle", "managedDependencies",
5454
"customHandler", "httpWorker"
5555
};

0 commit comments

Comments
 (0)