BenMorris / FunctionsCustomSercuity

A basic sample demonstrating how custom input binding can be used to support custom authentication for Azure Functions.
76 stars 22 forks source link

Update documentation with new IFunctionsHostBuilder on Configure method from Startup. #6

Closed germancasares closed 5 years ago

germancasares commented 5 years ago

Now that Azure functions have dependency injection built-in, as per https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection.

What should we do instead of :

[assembly: WebJobsStartup(typeof(Startup))]
namespace FunctionsCustomSercuity
{
    /// <summary>
    /// Runs when the Azure Functions host starts.
    /// </summary>
    public class Startup : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
            builder.AddAccessTokenBinding();
        }
    }
}
BenMorris commented 5 years ago

The solution will look a lot more like this branch:

https://github.com/BenMorris/FunctionsCustomSercuity/tree/NativeInjectionSupport

The only downside of using the new native DI is that you have to remember to call a validation method on every function. Probably not too great a burden.

I'll update all the main code (and related blog post) soon.

BenMorris commented 5 years ago

The main branch and blog post have been updated with both approaches. That said, dependency injection involves much less code so is the approach I would recommend.