Giter Club home page Giter Club logo

Comments (5)

jviau avatar jviau commented on June 28, 2024

@swettstein AspNetCore registration is also an extension using the same hook as your example. We offer no ordering control for this way of registering middleware, so this would be a new feature to offer that ability via the attribute route.

For now, if you need to control the middleware timing, users will need to register it during ConfigureFunctionsWorkerDefaults callback - as that will happen after extension middleware is automatically registered.

from azure-functions-dotnet-worker.

swettstein avatar swettstein commented on June 28, 2024

controlling the order of extension middleware would be a nice feature but there is some complexity there and probably not necessary in this case.

the AspNetCore extension doesn't use WorkerExtensionStartup but rather depends on users correctly applying an extension method from FunctionsHostBuilderExtensions. none of the other built-in extensions operate this way so why is this one different?

why couldn't the AspNetCore extension be internally smarter about how it gets registered by ensuring that its middleware gets inserted first?

from azure-functions-dotnet-worker.

fabiocav avatar fabiocav commented on June 28, 2024

Keeping this item in the backlog, as it is a valid request/gap, but this is low priority and there are no plans to have this worked on at the moment.

from azure-functions-dotnet-worker.

jviau avatar jviau commented on June 28, 2024

the AspNetCore extension doesn't use WorkerExtensionStartup but rather depends on users correctly applying an extension method from FunctionsHostBuilderExtensions. none of the other built-in extensions operate this way so why is this one different?

The reason for this comes down to needing access to the IHostBuilder, which WorkerExtensionStartup does not offer.

why couldn't the AspNetCore extension be internally smarter about how it gets registered by ensuring that its middleware gets inserted first?

For the same reason other extensions do not control order of middleware: there is no API for that. The extension only accesses public APIs from our worker assemblies, so it has no more privilege at setting a middleware first than any other extension does.

Addressing both of these points would require a non-trivial overhaul of some of our public APIs - which is not a priority at this point.

from azure-functions-dotnet-worker.

swettstein avatar swettstein commented on June 28, 2024

The reason for this comes down to needing access to the IHostBuilder, which WorkerExtensionStartup does not offer.

Some of it needs access to IHostBuilder but adding the FunctionsHttpProxyingMiddleware does not. It happens in an extension of IFunctionsWorkerApplicationBuilder which is accessible from WorkerExtensionStartup. regardless, with no guaranteed ordering of loading Extension Startups, the only way to guarantee my custom middleware is after the proxying middleware is to register it in ConfigureFunctionsWebApplication like i've already done for the workaround above.

i agree setting middleware priority would be non-trivial, especially when some of them are anonymous delegates. but what may be easier to do is priority of WorkerExtensionStartup through additional properties on the WorkerExtensionStartupAttribute. either way it's not high on your priority list.

ultimately if i'm creating an extension that's dependent on another extension, i would like to control the timing/ordering within my extension rather than depending on end users to get it right.

from azure-functions-dotnet-worker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.