Skip to content

Switch from Grpc.Core to Grpc.Net.Client #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
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
18 changes: 14 additions & 4 deletions src/Messaging/MessagingStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;

using Grpc.Core;
using Grpc.Net.Client;
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;

namespace Microsoft.Azure.Functions.PowerShellWorker.Messaging
Expand All @@ -19,15 +20,24 @@ internal class MessagingStream

internal MessagingStream(string host, int port)
{
// To call unsecured gRPC services, ensure the address starts with 'http' as opposed to 'https'.
// For more detail, see https://docs.microsoft.com/en-us/aspnet/core/grpc/client?view=aspnetcore-6.0
string uriString = $"http://{host}:{port}";
if (!Uri.TryCreate(uriString, UriKind.Absolute, out Uri grpcUri))
{
throw new InvalidOperationException($"The gRPC channel URI '{uriString}' could not be parsed.");
}

const int maxMessageLength = int.MaxValue;

var channelOptions = new []
var channelOptions = new GrpcChannelOptions
{
new ChannelOption(ChannelOptions.MaxReceiveMessageLength, maxMessageLength),
new ChannelOption(ChannelOptions.MaxSendMessageLength, maxMessageLength)
MaxReceiveMessageSize = maxMessageLength,
MaxSendMessageSize = maxMessageLength,
Credentials = ChannelCredentials.Insecure
};

Channel channel = new Channel(host, port, ChannelCredentials.Insecure, channelOptions);
GrpcChannel channel = GrpcChannel.ForAddress(grpcUri, channelOptions);
_call = new FunctionRpc.FunctionRpcClient(channel).EventStream();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Azure.Functions.PowerShellWorker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Licensed under the MIT license. See LICENSE file in the project root for full li
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.Core" Version="2.27.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.42.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.1" />
<PackageReference Include="CommandLineParser" Version="2.3.0" />
<PackageReference Include="Google.Protobuf" Version="3.19.4" />
Expand Down