File tree Expand file tree Collapse file tree 7 files changed +25
-37
lines changed
HttpTrigger-RetryFunctionJson
HttpTrigger-RetryHostJson
WebJobs.Script.Tests.Integration Expand file tree Collapse file tree 7 files changed +25
-37
lines changed Original file line number Diff line number Diff line change 1
- var invocationCount = 0 ;
2
- var errorString = 'An error occurred' ;
1
+ var errorString = 'An error occurred' ;
2
+ var maxRetries = 4 ;
3
3
4
4
module . exports = async function ( context , req ) {
5
- if ( context . executionContext . retryContext && ( context . executionContext . retryContext . retryCount !== invocationCount
6
- || ! ( context . executionContext . retryContext . maxRetryCount === 4 || context . executionContext . retryContext . maxRetryCount === 0 )
7
- || ! ( context . executionContext . retryContext . exception . message . includes ( errorString ) ) ) ) {
5
+ var retryContext = context . executionContext . retryContext ;
6
+
7
+ if ( retryContext . maxRetryCount != maxRetries || ( retryContext . retryCount > 0 && ! retryContext . exception . message . includes ( errorString ) ) ) {
8
8
context . res = {
9
9
status : 500
10
10
} ;
11
11
} else {
12
- const reset = req . query . reset ;
13
- invocationCount = reset ? 0 : invocationCount
14
-
15
- context . log ( 'JavaScript HTTP trigger function processed a request.invocationCount: ' + invocationCount ) ;
12
+ context . log ( 'JavaScript HTTP trigger function processed a request. retryCount: ' + retryContext . retryCount ) ;
16
13
17
- invocationCount = invocationCount + 1 ;
18
- const responseMessage = "invocationCount: " + invocationCount ;
19
- if ( invocationCount < 4 ) {
14
+ if ( retryContext . retryCount < maxRetries ) {
20
15
throw new Error ( errorString ) ;
21
16
}
22
17
context . res = {
23
- // status: 200, /* Defaults to 200 */
24
- body : responseMessage
18
+ body : 'retryCount: ' + retryContext . retryCount
25
19
} ;
26
20
}
27
21
}
Original file line number Diff line number Diff line change 1
- var invocationCount = 0 ;
2
- var errorString = 'An error occurred' ;
1
+ var errorString = 'An error occurred' ;
2
+ var maxRetries = 2 ;
3
3
4
4
module . exports = async function ( context , req ) {
5
- if ( context . executionContext . retryContext && ( context . executionContext . retryContext . retryCount !== invocationCount
6
- || ! ( context . executionContext . retryContext . maxRetryCount === 2 || context . executionContext . retryContext . maxRetryCount === 0 )
7
- || ! ( context . executionContext . retryContext . exception . message . includes ( errorString ) ) ) ) {
5
+ var retryContext = context . executionContext . retryContext ;
6
+
7
+ if ( retryContext . maxRetryCount != maxRetries || ( retryContext . retryCount > 0 && ! retryContext . exception . message . includes ( errorString ) ) ) {
8
8
debugger ;
9
9
context . res = {
10
10
status : 500
11
11
} ;
12
12
} else {
13
- const reset = req . query . reset ;
14
- invocationCount = reset ? 0 : invocationCount
15
-
16
- context . log ( 'JavaScript HTTP trigger function processed a request.invocationCount: ' + invocationCount ) ;
13
+ context . log ( 'JavaScript HTTP trigger function processed a request. retryCount: ' + retryContext . retryCount ) ;
17
14
18
- invocationCount = invocationCount + 1 ;
19
- const responseMessage = "invocationCount: " + invocationCount ;
20
- if ( invocationCount < 2 ) {
21
- throw new Error ( 'An error occurred' ) ;
15
+ if ( retryContext . retryCount < maxRetries ) {
16
+ throw new Error ( errorString ) ;
22
17
}
23
18
context . res = {
24
- // status: 200, /* Defaults to 200 */
25
- body : responseMessage
19
+ body : 'retryCount: ' + retryContext . retryCount
26
20
} ;
27
21
}
28
22
}
Original file line number Diff line number Diff line change 67
67
<PackageReference Include =" Microsoft.Azure.AppService.Proxy.Client" Version =" 2.0.11020001-fabe022e" />
68
68
<PackageReference Include =" Microsoft.Azure.Services.AppAuthentication" Version =" 1.0.3" />
69
69
<PackageReference Include =" Microsoft.Azure.Storage.File" Version =" 11.1.7" />
70
- <PackageReference Include =" Microsoft.Azure.WebJobs" Version =" 3.0.27 " />
71
- <PackageReference Include =" Microsoft.Azure.WebJobs.Host.Storage" Version =" 4.0.1 " />
70
+ <PackageReference Include =" Microsoft.Azure.WebJobs" Version =" 3.0.28 " />
71
+ <PackageReference Include =" Microsoft.Azure.WebJobs.Host.Storage" Version =" 4.0.2 " />
72
72
<PackageReference Include =" Microsoft.Azure.KeyVault" Version =" 3.0.3" />
73
73
<PackageReference Include =" Microsoft.Azure.WebJobs.Logging" Version =" 4.0.2" />
74
74
<PackageReference Include =" Microsoft.Azure.WebSites.DataProtection" Version =" 2.1.91-alpha" />
Original file line number Diff line number Diff line change 44
44
<PackageReference Include =" Microsoft.Azure.Functions.NodeJsWorker" Version =" 2.1.1" />
45
45
<PackageReference Include =" Microsoft.Azure.Functions.PowerShellWorker.PS6" Version =" 3.0.630" />
46
46
<PackageReference Include =" Microsoft.Azure.Functions.PowerShellWorker.PS7" Version =" 3.0.738" />
47
- <PackageReference Include =" Microsoft.Azure.WebJobs" Version =" 3.0.27 " />
47
+ <PackageReference Include =" Microsoft.Azure.WebJobs" Version =" 3.0.28 " />
48
48
<PackageReference Include =" Microsoft.Azure.WebJobs.Extensions" Version =" 4.0.3" />
49
49
<PackageReference Include =" Microsoft.Azure.WebJobs.Extensions.Http" Version =" 3.1.0" />
50
- <PackageReference Include =" Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version =" 3.0.27 " />
50
+ <PackageReference Include =" Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version =" 3.0.28 " />
51
51
<PackageReference Include =" Microsoft.Azure.WebJobs.Script.Abstractions" Version =" 1.0.2-preview" />
52
52
<PackageReference Include =" Microsoft.Build" Version =" 15.8.166" />
53
53
<PackageReference Include =" Microsoft.CodeAnalysis.CSharp.Scripting" Version =" 3.3.1" />
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public async Task HttpTrigger_RetryFunctionJson_Get_Succeeds()
32
32
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
33
33
string body = await response . Content . ReadAsStringAsync ( ) ;
34
34
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . MediaType ) ;
35
- Assert . Equal ( "invocationCount : 4" , body ) ;
35
+ Assert . Equal ( "retryCount : 4" , body ) ;
36
36
}
37
37
38
38
[ Fact ]
@@ -42,7 +42,7 @@ public async Task HttpTrigger_RetryHostJson_Get_Succeeds()
42
42
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
43
43
string body = await response . Content . ReadAsStringAsync ( ) ;
44
44
Assert . Equal ( "text/plain" , response . Content . Headers . ContentType . MediaType ) ;
45
- Assert . Equal ( "invocationCount : 2" , body ) ;
45
+ Assert . Equal ( "retryCount : 2" , body ) ;
46
46
}
47
47
48
48
public class TestFixture : EndToEndTestFixture
Original file line number Diff line number Diff line change 39
39
<PackageReference Include =" Microsoft.Azure.DocumentDB.Core" Version =" 2.10.0" />
40
40
<PackageReference Include =" Microsoft.Azure.EventHubs" Version =" 2.1.0" />
41
41
<PackageReference Include =" Microsoft.Azure.Functions.NodeJsWorker" Version =" 2.1.1" />
42
- <PackageReference Include =" Microsoft.Azure.WebJobs.Extensions.Storage" Version =" 4.0.3 " />
42
+ <PackageReference Include =" Microsoft.Azure.WebJobs.Extensions.Storage" Version =" 4.0.4 " />
43
43
<PackageReference Include =" Microsoft.Azure.Functions.JavaWorker" Version =" 1.8.2-SNAPSHOT" />
44
44
<PackageReference Include =" Microsoft.Azure.Mobile.Client" Version =" 4.0.2" />
45
45
<PackageReference Include =" Microsoft.Azure.ServiceBus" Version =" 3.1.0" />
Original file line number Diff line number Diff line change 55
55
<PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 15.8.0" />
56
56
<PackageReference Include =" Moq" Version =" 4.9.0" />
57
57
<PackageReference Include =" StyleCop.Analyzers" Version =" 1.1.0-beta004" />
58
- <PackageReference Include =" Microsoft.Azure.WebJobs.Extensions.Storage" Version =" 4.0.3 " />
58
+ <PackageReference Include =" Microsoft.Azure.WebJobs.Extensions.Storage" Version =" 4.0.4 " />
59
59
<PackageReference Include =" System.IO.Abstractions.TestingHelpers" Version =" 2.1.0.227" >
60
60
</PackageReference >
61
61
<PackageReference Include =" xunit" Version =" 2.4.0" />
You can’t perform that action at this time.
0 commit comments