Skip to content

Commit 7324b15

Browse files
authored
Custom Handler Proxying (#11035)
1 parent bcbf3c1 commit 7324b15

22 files changed

+236
-44
lines changed

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
- Improvements to coldstart pipeline (#11102).
1818
- Update Python Worker Version to [4.38.0](https://github.com/Azure/azure-functions-python-worker/releases/tag/4.38.0)
1919
- Only start the Diagnostic Events flush logs timer when events are present, preventing unnecessary flush attempts (#11100).
20+
- Enable HTTP proxying for custom handlers (#11035)
2021
- Switched memory usage reporting to use CGroup metrics by default for Linux consumption (#11114)

src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using Microsoft.Azure.WebJobs.Script.Grpc.Eventing;
2727
using Microsoft.Azure.WebJobs.Script.Grpc.Extensions;
2828
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
29+
using Microsoft.Azure.WebJobs.Script.Http;
2930
using Microsoft.Azure.WebJobs.Script.ManagedDependencies;
3031
using Microsoft.Azure.WebJobs.Script.Workers;
3132
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;

src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannelFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.Azure.WebJobs.Script.Diagnostics;
99
using Microsoft.Azure.WebJobs.Script.Eventing;
1010
using Microsoft.Azure.WebJobs.Script.Grpc.Eventing;
11+
using Microsoft.Azure.WebJobs.Script.Http;
1112
using Microsoft.Azure.WebJobs.Script.Workers;
1213
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
1314
using Microsoft.Azure.WebJobs.Script.Workers.SharedMemoryDataTransfer;

src/WebJobs.Script.Grpc/GrpcServiceCollectionsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
5+
using Microsoft.Azure.WebJobs.Script.Http;
56
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
67
using Microsoft.Extensions.DependencyInjection;
78

src/WebJobs.Script.Grpc/WebJobs.Script.Grpc.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
1919
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
2020
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
21-
<PackageReference Include="Yarp.ReverseProxy" Version="2.0.1" />
2221
</ItemGroup>
2322

2423
<ItemGroup>

src/WebJobs.Script.WebHost/Middleware/FunctionInvocationMiddleware.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
using System.Collections.Generic;
55
using System.Diagnostics;
66
using System.Linq;
7-
using System.Threading;
87
using System.Threading.Tasks;
98
using Microsoft.AspNetCore.Authorization.Policy;
10-
using Microsoft.AspNetCore.Hosting;
119
using Microsoft.AspNetCore.Http;
1210
using Microsoft.AspNetCore.Mvc;
1311
using Microsoft.AspNetCore.Mvc.Abstractions;
@@ -57,9 +55,9 @@ public async Task Invoke(HttpContext context)
5755
int nestedProxiesCount = GetNestedProxiesCount(context, functionExecution);
5856
IActionResult result = await GetResultAsync(context, functionExecution);
5957

60-
if (context.Items.TryGetValue(ScriptConstants.HttpProxyingEnabled, out var value))
58+
if (context.Items.TryGetValue(ScriptConstants.HttpProxyingEnabled, out var httpProxyingEnabled))
6159
{
62-
if (value?.ToString() == bool.TrueString)
60+
if (httpProxyingEnabled?.ToString() == bool.TrueString)
6361
{
6462
return;
6563
}

src/WebJobs.Script/Description/Workers/ScriptInvocationResult.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System.Collections.Generic;
5+
using System.Collections.Immutable;
56

67
namespace Microsoft.Azure.WebJobs.Script.Description
78
{
89
public class ScriptInvocationResult
910
{
11+
public static readonly ScriptInvocationResult Success = new ScriptInvocationResult
12+
{
13+
Outputs = ImmutableDictionary<string, object>.Empty
14+
};
15+
1016
public object Return { get; set; }
1117

1218
public IDictionary<string, object> Outputs { get; set; }

src/WebJobs.Script.Grpc/Exceptions/HttpForwardingException.cs renamed to src/WebJobs.Script/Exceptions/HttpForwardingException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55

6-
namespace Microsoft.Azure.WebJobs.Script.Grpc.Exceptions
6+
namespace Microsoft.Azure.WebJobs.Script.Exceptions
77
{
88
internal class HttpForwardingException : Exception
99
{

src/WebJobs.Script.Grpc/Server/DefaultHttpProxyService.cs renamed to src/WebJobs.Script/Http/DefaultHttpProxyService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
using System.Threading.Tasks;
88
using Microsoft.AspNetCore.Http;
99
using Microsoft.Azure.WebJobs.Script.Description;
10-
using Microsoft.Azure.WebJobs.Script.Grpc.Exceptions;
10+
using Microsoft.Azure.WebJobs.Script.Exceptions;
1111
using Microsoft.Azure.WebJobs.Script.Workers;
1212
using Microsoft.Extensions.Logging;
1313
using Yarp.ReverseProxy.Forwarder;
1414

15-
namespace Microsoft.Azure.WebJobs.Script.Grpc
15+
namespace Microsoft.Azure.WebJobs.Script.Http
1616
{
1717
internal class DefaultHttpProxyService : IHttpProxyService, IDisposable
1818
{

src/WebJobs.Script/Http/DefaultHttpRouteManager.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
5-
using Microsoft.Azure.WebJobs.Script.WebHost;
6-
74
namespace Microsoft.Azure.WebJobs.Script.Http
85
{
96
internal class DefaultHttpRouteManager : IHttpRoutesManager

0 commit comments

Comments
 (0)