Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions host/src/FunctionsNetHost/Grpc/IncomingGrpcMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@ private async Task Process(StreamingMessage msg)
Logger.LogTrace("Specialization request received.");

var envReloadRequest = msg.FunctionEnvironmentReloadRequest;
var applicationExePath = PathUtils.GetApplicationExePath(envReloadRequest.FunctionAppDirectory);
Logger.LogTrace($"application path {applicationExePath}");

if (string.IsNullOrWhiteSpace(applicationExePath))
{
var ex = new InvalidOperationException($"Unable to find a valid function app payload at '{envReloadRequest.FunctionAppDirectory}'");
responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(ex);
Comment thread
kshyju marked this conversation as resolved.
Outdated
break;
}

foreach (var kv in envReloadRequest.EnvironmentVariables)
{
EnvironmentUtils.SetValue(kv.Key, kv.Value);
}

var applicationExePath = PathUtils.GetApplicationExePath(envReloadRequest.FunctionAppDirectory);
Logger.LogTrace($"application path {applicationExePath}");

#pragma warning disable CS4014
Task.Run(() =>
#pragma warning restore CS4014
Expand All @@ -74,7 +81,31 @@ private async Task Process(StreamingMessage msg)
break;
}

await MessageChannel.Instance.SendOutboundAsync(responseMessage);
if (responseMessage.ContentCase != StreamingMessage.ContentOneofCase.None)
{
await MessageChannel.Instance.SendOutboundAsync(responseMessage);
}
}

private static FunctionEnvironmentReloadResponse BuildFailedEnvironmentReloadResponse(Exception exception)
{
var rpcException = new RpcException
{
Message = exception.ToString(),
Source = exception.Source ?? string.Empty,
StackTrace = exception.StackTrace ?? string.Empty
};

var response = new FunctionEnvironmentReloadResponse
{
Result = new StatusResult
{
Status = StatusResult.Types.Status.Failure,
Exception = rpcException
}
};

return response;
}

private static FunctionMetadataResponse BuildFunctionMetadataResponse()
Expand Down