0

I'm trying to setup dependency injection with Azure functions but for whatever reason I can't get the web jobs start up method to fire.

[assembly: WebJobsStartup(typeof(PersonalBlog.Functions.Content.RefreshContentStartup))]
namespace PersonalBlog.Functions.Content { 
    public class RefreshContentStartup : IWebJobsStartup {
        public void Configure(IWebJobsBuilder builder) { }
    }
}

The project is .net Framework 4.7.1 due to the fact that it has a dependency on a few libraries that haven't been converted to dot net core yet...

Is there something I'm missing here? Do I have to add a setting for it to pick up on my startup file?

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
The Pax Bisonica
  • 2,154
  • 2
  • 26
  • 45
  • 1
    I don't think V2 supports .NET Framework. – Kirk Larkin Apr 16 '19 at 13:59
  • I can get the function running locally, it just doesn't hit the startup method.. I'd be surprised if it didn't support .net framework, I thought part of the point of using functions was so that you could run it using any language/runtime. – The Pax Bisonica Apr 16 '19 at 14:48
  • 1
    Maybe things have changed, but [this answer](https://stackoverflow.com/questions/50101379/azure-function-v2-net-framework) suggests it cannot be done (the [docs](https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions#languages) point at V2 = .NET Core also). I've got the same setup as you in a .NET Core environment and it works. – Kirk Larkin Apr 16 '19 at 14:51
  • 1
    @KirkLarkin is correct. Azure Functions v2 only support .netcore (when it comes to .NET). For .NET Framework you need to use Functions v1 – silent Apr 16 '19 at 15:11

1 Answers1

1

As @Kirklarkin and @silent mentionned, Azure Functions v2 supports .NET Core whereas Azure Functions v1 supports .NET Framework. You can't run Azure Functions on any languages/runtime, there is a list of supported languages with the associated runtimes. The point of using Azure Functions is mostly to do serverless which means autoscaling, no infrastructure to manage, and paying resources per use.

Concerning dependency injection, it is not supported out-of-the box in Azure Functions at the time of writing but the team is currently implementing it and it's one of their top priorities so we should have it soon.

TechWatching
  • 1,363
  • 1
  • 11
  • 23