Skip to content

Commit 07b923d

Browse files
committed
Handle FunctionEnvironmentReloadRequest (#441)
1 parent 4551350 commit 07b923d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/RequestProcessor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,19 @@ internal StreamingMessage ProcessInvocationCancelRequest(StreamingMessage reques
339339

340340
internal StreamingMessage ProcessFunctionEnvironmentReloadRequest(StreamingMessage request)
341341
{
342+
var stopwatch = new Stopwatch();
343+
stopwatch.Start();
344+
345+
var environmentReloadRequest = request.FunctionEnvironmentReloadRequest;
346+
foreach (var (name, value) in environmentReloadRequest.EnvironmentVariables)
347+
{
348+
Environment.SetEnvironmentVariable(name, value);
349+
}
350+
351+
var rpcLogger = new RpcLogger(_msgStream);
352+
rpcLogger.SetContext(request.RequestId, null);
353+
rpcLogger.Log(isUserOnlyLog: false, LogLevel.Trace, string.Format(PowerShellWorkerStrings.EnvironmentReloadCompleted, stopwatch.ElapsedMilliseconds));
354+
342355
StreamingMessage response = NewStreamingMessageTemplate(
343356
request.RequestId,
344357
StreamingMessage.ContentOneofCase.FunctionEnvironmentReloadResponse,

src/resources/PowerShellWorkerStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,7 @@
313313
<data name="InvalidFunctionsWorkerRuntimeVersion" xml:space="preserve">
314314
<value>Invalid PowerShell version specified in the {0} environment variable: {1}. This version is not supported on Azure Functions Runtime v2.</value>
315315
</data>
316+
<data name="EnvironmentReloadCompleted" xml:space="preserve">
317+
<value>Environment reload completed in {0} ms.</value>
318+
</data>
316319
</root>

0 commit comments

Comments
 (0)