Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Support OData queries

Open TimNilimaa opened this issue 6 years ago • 41 comments

Would love to see support for OData queries to functions, so that one could build an odata compliant service using Functions rather than an app service. OData supports .net core now, so the way to support this should be too far away. Today one might use parsers of the querystring but it doesn't work 100% of the time.

TimNilimaa avatar Nov 22 '18 08:11 TimNilimaa

@mattchenderson

ColbyTresness avatar Mar 13 '19 19:03 ColbyTresness

This would be great!

josmithua avatar Apr 04 '19 00:04 josmithua

We would really benefit from this. We are looking at moving away from Azure functions due to the missing support for OData. But would rather not as we really like the Azure Functions.

hanneslarsson avatar Jun 04 '19 09:06 hanneslarsson

I also was looking for this feature and would like if u guys supported it, i am unable to move 2 projects at this point to azure functions because of the lack of odata support.

christophedemey avatar Jul 17 '19 17:07 christophedemey

I have a workaround while official support is being developed: https://github.com/aletc1/examples-odata-azure-functions,

Full details in: https://www.algohace.net/posts/odata-en-azure-functions-v2 (Spanish only)

aletc1 avatar Aug 09 '19 01:08 aletc1

We also wanna switch from Azure App Service to Azure Function. Would be great for our project too! Because we use OData in our Azure App Services we can't switch to Azure Functions.

BHuber-PlanB avatar Nov 28 '19 12:11 BHuber-PlanB

We had a simple need, support GET requests with odata syntax. Thanks to the extension method provided by @aletc1 I was able to spend a few hours this afternoon and came up with a simple binding extension that has support for the EnableQuery attribute as shown here.

[EnableQuery(MaxTop = 100, AllowedQueryOptions = AllowedQueryOptions.Select | AllowedQueryOptions.Filter | AllowedQueryOptions.Top)]
[FunctionName("products")]
public static Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
    ODataQueryOptions<Product> odata,
    ILogger log)
{
    var data = new List<Product>
    {
        new Product { Sku = 1, Name = "Apple" },
        new Product { Sku = 2, Name = "Lettuce" }
    };

    return Task.FromResult<IActionResult>(new OkObjectResult(odata.ApplyTo(data.AsQueryable())));
}

smokedlinq avatar Jan 26 '20 20:01 smokedlinq

This would be super helpful for us to use in conjunction with Power BI rather than giving either raw database access or use an App Service 👍

deepbass avatar Apr 06 '20 10:04 deepbass

Is there any workaround for v3?

alexmartinezm avatar Apr 20 '20 12:04 alexmartinezm

Bear in mind that there's an open bug related to "select" clauses... https://github.com/OData/WebApi/issues/2118

alexmartinezm avatar Apr 28 '20 14:04 alexmartinezm

Is there any workaround for v3?

@alexmartinezm -- I just pushed an update that makes this work for v3 Azure Functions

smokedlinq avatar Jul 09 '20 13:07 smokedlinq

Great solution @smokedlinq Works just great! Are you going to publish as a Nuget package?

steven-pearson avatar Aug 30 '20 07:08 steven-pearson

Not sure. I'm the furthest thing from an OData expert. I'm pretty sure I shouldn't publish it with the Microsoft prefix on the NuGet package if I do, so I'll first have to come up with a project name/code. ;p

smokedlinq avatar Aug 31 '20 00:08 smokedlinq

+1 :)

crgarcia12 avatar Sep 09 '20 06:09 crgarcia12

@alexmartinezm @steven-pearson FYI I just moved this over to a new repo for my function extensions and published a nuget package AzureFunctions.Extensions.OData.

smokedlinq avatar Sep 18 '20 13:09 smokedlinq

1+ Would be very nice to have official support for https://github.com/OData/aspnetcoreodata

jacobmohl avatar Feb 27 '21 09:02 jacobmohl

+1

jhulbertpmn avatar Mar 19 '21 21:03 jhulbertpmn

+1

daisukei777 avatar May 14 '21 01:05 daisukei777

+1 please officially implement this. Thank you.

CiroDiMarzo avatar Sep 28 '21 14:09 CiroDiMarzo

This issue is 3 years old and is now onto its 3rd version of Azure Functions since the issue was raised. And still no OData implementation from Microsoft - only community workarounds.

How has this not been a priority? Does Microsoft feel that paging, sorting, and filtering of data is not important? Or that these features don't warrant an official framework solution?

Does anybody have any current workaround for Azure Functions v4; .Net6.0? This is bordering on being a deal-breaker for the platform as-is.

challamzinniagroup avatar Nov 29 '21 00:11 challamzinniagroup

+1 please officially support this! without it, azure functions isn't working out to be a good option for api.

apoorvmintri avatar Jan 12 '22 11:01 apoorvmintri

+1. Please officially add this to the product pipeline. Thank you!!

gadusumi avatar Feb 01 '22 04:02 gadusumi

Tagging @fabiocav to see if this being considered in the new Isolated model

mayank88mahajan avatar Mar 10 '22 21:03 mayank88mahajan

Please add this support, we are now unable to move to Functions V4 / .Net 6 as the community workaround has stopped supporting it.

https://github.com/smokedlinq-archive/Microsoft.Azure.WebJobs.Extensions.OData

PatrikNorrgard avatar Mar 17 '22 09:03 PatrikNorrgard

Not ideal but consider creating an api and hosting it as a web app on azure.

david-nguyen avatar Apr 19 '22 17:04 david-nguyen

Not ideal but consider creating an api and hosting it as a web app on azure.

Apologies, I'm not sure if I understand what you are suggesting.

If you mean to avoid functions altogether and revert to the "old way" of doing things (.Net Core WebApis hosted as AppServices) - this is essentially the decision I have made in those instances where OData is required (which is almost every project). It's simply not practical to create a custom data fetching solution - this problem was solved years ago. Microsoft took three steps backwards on this with Functions and has remained there, giving zero indication as to whether they are even considering implementation of a basic feature.

For all the promise of serverless computing; Microsoft has not really been at the top of the game by a fair margin. Just as one small example of questionable priority decisions; Microsoft recently added Swagger/OpenAPI to Functions. And while I am all for this - there is no way this was more needed than formal OData support. OpenAPI is a nice to have while OData is a need.

challamzinniagroup avatar Apr 20 '22 12:04 challamzinniagroup

Not ideal but consider creating an api and hosting it as a web app on azure.

Apologies, I'm not sure if I understand what you are suggesting.

If you mean to avoid functions altogether and revert to the "old way" of doing things (.Net Core WebApis hosted as AppServices) - this is essentially the decision I have made in those instances where OData is required (which is almost every project). It's simply not practical to create a custom data fetching solution - this problem was solved years ago. Microsoft took three steps backwards on this with Functions and has remained there, giving zero indication as to whether they are even considering implementation of a basic feature.

For all the promise of serverless computing; Microsoft has not really been at the top of the game by a fair margin. Just as one small example of questionable priority decisions; Microsoft recently added Swagger/OpenAPI to Functions. And while I am all for this - there is no way this was more needed than formal OData support. OpenAPI is a nice to have while OData is a need.

Right that's why I said it is not ideal but given that microsoft has not addressed the issue for 3 years it's a possible solution.

david-nguyen avatar Apr 20 '22 15:04 david-nguyen

I love so much of what Functions represents, but then issues like this come up and remain unaddressed for years. These are things that prevent Functions from being an option for many users and businesses.

NSouth avatar Sep 11 '22 13:09 NSouth

Another vote for this please. I have a need for a simple GET endpoint to fetch data from an EFCore data store. This is relatively simple to achieve in ASP.NET Core WebApi, but I really need the scalability, flexibility and lower overheads/maintenance of an Azure Function.

ph-ict avatar Sep 14 '22 09:09 ph-ict

Bumping the thread. This is a very nice feature that is BROKEN. Evidently it used to work. Are new features > broken old features?

kazman71 avatar Nov 15 '22 19:11 kazman71