Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebJobsStartup in Azure Functions v2 not working when targeting netcoreapp2.1

I have an Azure Function v2 app, that I originally targeted netcoreapp2.1.

I then have a Startup.cs class, annotated with [assembly: WebJobsStartup(typeof(Startup))] to set up dependency injection, but it did not register Startup in the extensions.json file.

This is happening during build. Publish has another issue at the moment.

When I change the TargetFramework in the project file to netstandard2.0 it successfully adds Startup to extensions.json:

{
  "extensions":[
    { "name": "AzureStorage", "typeName":"Microsoft.Azure.WebJobs.Extensions.Storage.AzureStorageWebJobsStartup, Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"},
    { "name": "Startup", "typeName":"MyApp.Functions.Startup, MyApp.Functions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"}
  ]
}

While I do not have exact reasons to target netcoreapp2.1, I am curious to figure out why it doesn't work, as v2 was changed to target .Net Core by default.

like image 724
MartinHN Avatar asked Oct 30 '18 10:10

MartinHN


People also ask

How do I change the runtime version of Azure function app?

In the Azure portal, browse to your function app. Under Settings, choose Configuration. In the Function runtime settings tab, locate the Runtime version. Note the specific runtime version.

Do Azure Functions support .NET 6?

NET to version 6. You can do that by updating to the new shiny Visual Studio 2022 with built-in SDK or downloading it from here: . NET 6.0 SDK. In Visual Studio 2022, Azure Functions Core Tools, necessary for developing Azure Functions, are available by adding the Azure Cloud Tool in the installation process of VS.

How do I troubleshoot Azure function?

Start Azure Functions diagnosticsNavigate to your function app in the Azure portal. Select Diagnose and solve problems to open Azure Functions diagnostics. Choose a category that best describes the issue of your function app by using the keywords in the homepage tile.


1 Answers

I have upgraded the Microsoft.NET.SDK.Functions to version 1.0.26 from manage nuget packages and it worked.

enter image description here

like image 100
Tharindu Jayasinghe Avatar answered Sep 24 '22 01:09

Tharindu Jayasinghe