Azure / Azure-Functions

1.11k stars 194 forks source link

Provide gRPC as a configurable endpoint trigger #771

Open Clockwork-Muse opened 6 years ago

Clockwork-Muse commented 6 years ago

Probably depends on #738 (at least evaluating how it interacts with billing). Definitely depends on the wider Azure infrastructure supporting HTTP/2. HTTP/2 is now supported by API Gateways, although it's off by default (and it's not clear how far this support extends).

Will almost certainly require work in the various host/runners to provide the necessary support.

paulbatum commented 6 years ago

@Clockwork-Muse Can you provide more detail on the value proposition (perhaps some example scenarios that would benefit from this) and what you would expect the programming model to look like (e.g. an example function using this trigger)?

Clockwork-Muse commented 6 years ago

Well, there are performance arguments to make, but I feel that's somewhat of a minor point to try to reach for.

Many of the benefits follow from the use of WebSockets and HTTP/2 generally - the ability to keep a connection between client and server open, bidirectional streams, and closer-to-native async/cancellable code. Further, it has interesting implications for load balancing, because some of the current function hosts are actually set up as gRPC endpoints.


For the programming model, many simple cases are liable to look not materially different than they do today (taken from the gRPC getting started samples):

public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
{
    return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
}

Some of the real benefits happen for cases that gRPC handles well, like streaming results back to the client (from the gRPC streaming tutorial):

public override async Task ListFeatures(Rectangle request,
    IServerStreamWriter<Feature> responseStream,
    ServerCallContext context)
{
    var responses = features.FindAll(feature => feature.Exists() && request.Contains(feature.Location));
    foreach (var response in responses)
    {
        await responseStream.WriteAsync(response);
    }
}

To do this currently requires manually allocating a queue the client can tap into, or as a binary blob. Except a queue object would be shared, whereas a gRPC stream is part of the connection, and the binary blob would require manual de/serialization.

paulbatum commented 6 years ago

Thanks. I agree with your linking to #738 as some of the challenges I mentioned there apply here too - websockets and GRPC are stateful protocols while functions has a stateless programming model and it is not exactly obvious how to reconcile the two. That simple server side streaming example could probably be adapted to work OK with the functions programming model because its not that hard to define the "start" and the "end" of the execution. But take the bidirectional streaming example and its much tougher...

Clockwork-Muse commented 6 years ago

Agreed.

Now, I imagine simple request/response would comprise probably 90% of use cases, so it might be possible to expose just that capability (certainly all of my stuff falls into that category for now), but even that is likely to take a while.

ckoehler-pillar commented 4 years ago

any updates on this?

paulbatum commented 4 years ago

@ckoehler-pillar no updates at this time.

MikesGlitch commented 4 years ago

This could be great for using with Blazor.

ckoehler-pillar commented 4 years ago

how about now?

ChiefInnovator commented 4 years ago

Been doing some work on Azure Functions and gRPC separately. Now those efforts want to combine. Any update on an endpoint trigger for gRPC?

ErickSvalinn commented 3 years ago

Is there some updates on this thread? With C# 9 drastically improving the performance of gRPC, we really need this as and endpoint. I'm ready to use it on production environments

paulbatum commented 3 years ago

There's no ETA for this functionality, but I can at least spell out some of the things that would need to happen to make it a reality:

  1. App Service needs to support gRPC (since Azure Functions and App Service run on the same infrastructure). There is a user voice item for that here. I believe that has its own set of dependencies, one of which is the work described here.
  2. Determine whether scoping down to shortlived request/response patterns is enough. If so, it fits well with the functions programming model, which is stateless and also would fit well with the consumption billing model that requires an explicit start/stop event and has a max execution time.
  3. Build the gRPC trigger implementation based on wherever we end up on point 2
  4. Figure out how to best handle dynamic scaling for gRPC workloads and get that implemented.
georghildebrand commented 3 years ago

@paulbatum was there any update in the last 4 months? Its wired to see no progress on such an important topics for so a long time.

paulbatum commented 3 years ago

I'm not aware of any changes. I believe that App Service support for gRPC is still the major blocker.

esimkowitz commented 3 years ago

@paulbatum any update here?

paulbatum commented 3 years ago

I'm not aware of any changes. I believe that App Service support for gRPC is still the major blocker.

JasonTFifer commented 2 years ago

@paulbatum Is it possible to deploy an ASP.NET gRPC service to an Azure App Service? If so, would that provide the basis for the Azure Function functionality? I'm also very interested in being able to have gRPC as an Azure Functions trigger. Thanks!

holtalanm commented 2 years ago

are there any updates on this? Or are we still waiting on App Service support for gRPC?

bryanknox commented 2 years ago

Oh man. Patience is a virtue. In the meantime, . . . Here's the link to some of the related feedback.azure.com ideas (do we still call it user voice?):

Please up vote those.

bryanknox commented 2 years ago

Support for short lived gRPC request/response scenarios would be good enough for the use cases where I see gRPC being a good fit for use with Azure Functions. Streaming seems like a different can of worms. Maybe best fit for some new kind of Azure Function, if any.

crookm commented 2 years ago

I agree with @bryanknox that even partial support of gRPC would be awesome - though maybe a bit confusing for developers, I can imagine the sheer number of warning boxes on the docs page explaining the caveats, haha.

Personally, I like gRPC because of the rich tooling associated with it by default in .NET. Things like the automatic clients generated from the protos are excellent, and massively easier to work with than the Swagger/OpenAPI alternative. I don't need the bi-directional streaming that the full spec provides - which I imagine is very difficult to map to the consumption-based stateless function model anyway.

I wonder if a shorter-term solution of supporting the gRPC-Web protocol via an extension to the SDK set would be something the community would accept? Since gRPC-Web does not require HTTP2, I'm guessing it might not need infrastructure changes (unless I'm way off the mark). The support for server->client streaming might also hit a lot of developer's requirements as well, with the caveat of the maximum function runtime under consumption plans, of course.

vvicho commented 1 year ago

Looks like Azure App Service now supports gRPC according to this post https://azure.microsoft.com/en-us/updates/public-preview-grpc-support-in-azure-app-service/

QilinCloud commented 1 year ago

@paulbatum it looks like azure app service now supports gRPC. Do you now have any updates on this topic?

Maybe you can also have some words about the usage of gRPC on HTTP3 for API Management?

paulbatum commented 1 year ago

@QilinCloud Yes, App Service Linux now has support for gRPC. Earlier in this thread I commented about other work items that would have to happen, let me repaste that list and I'll do my best to expand on it, but please be aware I'm working with incomplete information.

  1. App Service Linux now supports gRPC (crucial given that Azure Functions and App Service run on the same infrastructure). This theoretically unblocks Azure Functions that are configured to run on Linux. It does not theoretically unblock Azure Functions that are configured to run on Windows. This would require a different set of work on the App Service side and I am not sure about the plans there.

I say theoretically unblock because there are various follow up work items that are quite large, that would still be required:

  1. Determine whether scoping down to shortlived request/response patterns is enough. If so, it fits well with the functions programming model, which is stateless and also would fit well with the consumption billing model that requires an explicit start/stop event and has a max execution time. This analysis would also have to figure out how rich the programming model experience needs to be to meet the customer scenarios, and whether there are additional challenges in supporting that across all our languages, particularly considering the fact they run out of proc from the functions host.
  2. Build the gRPC trigger implementation based on wherever we end up on point 2.
  3. Figure out how to best handle dynamic scaling for gRPC workloads and get that implemented.

I am not aware of any in-progress or planned work on 2,3 and 4 at this time.

I don't have any context on HTTP3 and API Management, sorry.

martonx commented 6 months ago

Hi all, please at least add shortlived request/response gRPC functionality to Azure Functions! I'm pretty sure on AF it could be enough in the 99% of the cases.