Reputation: 19772
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.
Upvotes: 12
Views: 3894
Reputation: 8669
In my case, I had simply missed to explicitly set host.json
to be copied. Adding these rows to the csproj
file did the works:
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Upvotes: 0
Reputation: 3191
I have upgraded the Microsoft.NET.SDK.Functions to version 1.0.26 from manage nuget packages and it worked.
Upvotes: 7
Reputation: 452
This looks fixed now just upgrade Microsoft.NET.SDK.Functions to version 1.0.25 +
Upvotes: 0