1

I am looking at the beta version of running .net core api in Google Cloud Functions.

https://cloud.google.com/functions/docs/quickstart-dotnet

I have a rest api running in AWS lambda and i am planning to to migrate to Google Cloud Functions.

I want to understand if we can run a full fledged api with multiple endpoints like api/method1 , api/method2 etc like lambda or is it not possible right now in google cloud function. Examples showed in the page just listens to a single url.

I also tried adding the

[FunctionsStartup(typeof(Startup))]

And in the startup, I added the controllers like below, but routing to the controller is not happening

public override void ConfigureServices(WebHostBuilderContext context, IServiceCollection services)
    {
        services.AddControllers();
    

Can someone please clarify?

2 Answers 2

1

The Functions Framework expects a single function to be registered. That function could itself perform additional routing based on the URI, and it's possible that you could use a lot of the built-in ASP.NET Core routing to do that, but it's not a scenario we're investing in right now. It sounds like you logically want multiple functions - so I'd suggest deploying it as multiple functions. Those multiple functions could still all be present in the same project if that's convenient for you - you'd just specify different entry points when you deploy.

Alternatively, you could use a regular ASP.NET Core app and deploy that to Cloud Run to retain the benefits of serverless pricing etc, if you only want a single deployment.

1
  • Hi @Jon Skeet, Thank you for your time in sharing your comments. yes, I am looking at cloud functions to host an API with all CRUD functionalities. I will check the Cloud Run now. Jan 19, 2021 at 5:23
1

@karthick, maybe check this out

see this article from google cloud "Exposing ASP.NET Web API using .NET Core with Cloud Endpoints" https://cloud.google.com/community/tutorials/exposing-aspnet-webapi-using-dotnetcore-with-cloud-endpoints

it does seem like all the api endpoints will automatically be exposed when following those steps.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.