Skip to content

Commit e332907

Browse files
authored
Ensuring JobHost restart suppresion aligns with request lifecycle (#10638)
1 parent da46c0e commit e332907

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
- Suppress `JwtBearerHandler` logs from customer logs (#10617)
88
- Updated System.Memory.Data reference to 8.0.1
99
- Address issue with HTTP proxying throwing `ArgumentException` (#10616)
10+
- Updated JobHost restart suppresion in functions APIs to align with request lifecycle (#10638)

src/WebJobs.Script.WebHost/Controllers/FunctionsController.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.AspNetCore.Http.Extensions;
1313
using Microsoft.AspNetCore.Mvc;
1414
using Microsoft.Azure.WebJobs.Extensions.Http;
15+
using Microsoft.Azure.WebJobs.Host;
1516
using Microsoft.Azure.WebJobs.Script.Description;
1617
using Microsoft.Azure.WebJobs.Script.Management.Models;
1718
using Microsoft.Azure.WebJobs.Script.WebHost.Extensions;
@@ -80,12 +81,10 @@ public async Task<IActionResult> CreateOrUpdate(string name, [FromBody] Function
8081
return BadRequest($"{name} is not a valid function name");
8182
}
8283

83-
bool success, configChanged;
84-
FunctionMetadataResponse functionMetadataResponse;
85-
using (fileMonitoringService.SuspendRestart(true))
86-
{
87-
(success, configChanged, functionMetadataResponse) = await _functionsManager.CreateOrUpdate(name, functionMetadata, Request);
88-
}
84+
var restartSuspensionScope = fileMonitoringService.SuspendRestart(true);
85+
Response.RegisterForDispose(restartSuspensionScope);
86+
87+
(bool success, _, FunctionMetadataResponse functionMetadataResponse) = await _functionsManager.CreateOrUpdate(name, functionMetadata, Request);
8988

9089
if (success)
9190
{
@@ -200,12 +199,10 @@ public async Task<IActionResult> Delete(string name, [FromServices] IFileMonitor
200199
return NotFound();
201200
}
202201

203-
bool deleted;
204-
string error;
205-
using (fileMonitoringService.SuspendRestart(true))
206-
{
207-
(deleted, error) = await _functionsManager.TryDeleteFunction(function);
208-
}
202+
var restartSuspensionScope = fileMonitoringService.SuspendRestart(true);
203+
Response.RegisterForDispose(restartSuspensionScope);
204+
205+
(bool deleted, string error) = await _functionsManager.TryDeleteFunction(function);
209206

210207
if (deleted)
211208
{

0 commit comments

Comments
 (0)