Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure function Publish not creating Startup class entry in extensions.json #972

Closed
ssathasivan opened this issue Oct 1, 2018 · 12 comments
Closed
Milestone

Comments

@ssathasivan
Copy link

ssathasivan commented Oct 1, 2018

We are developing a set of Azure functions for our new product. We are using dependency injection for our project following the strategy , mentioned in the following article

https://blog.wille-zone.de/post/azure-functions-dependency-injection/

and registered the extension in Startup.cs

This is working fine in the local development environment. However when we tried to publish it azure , the azure functions runtime was not detecting the injected dependencies . We found a similiar problem in the following sctak over flow.com post

https://stackoverflow.com/questions/52123538/iextensionconfigprovider-not-initializing-or-binding-with-microsoft-azure-webjob

We made changes as per their recommendation in the accepted answer. As per this

"In C# the SDK 1.0.19 looks at build time for classes attributed with WebJobsStartup assembly attribute in the current function project or any dependency (ProjectReference or PackageReference) of the current project, and generates the corresponding extensions.json file."

However we ran in to strange problem, When we do a release build , the startup class entry is created in the extensions.json

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

however when we try to publish , the startup class entry is NOT created in the extensions.json
{
"extensions":[
{ "name": "AzureStorage", "typeName":"Microsoft.Azure.WebJobs.Extensions.Storage.AzureStorageWebJobsStartup, Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
]
}

We are stumped and do not know what is the problem

We have created a issue for this in stackoverflow -

@BorisWilhelms
Copy link

There is a workaround for this issues posted in a different thread: Azure/azure-functions-host#3386 (comment)

@fabiocav
Copy link
Member

fabiocav commented Oct 3, 2018

Some of those issues are known limitations of the product at the moment. We are working on first class support for customer facing DI capabilities in Azure Functions, which will come with a full set of documentation, including services you can depend on and official guidance.

In the meantime, use of those undocumented patterns may be fragile in Azure Functions, which is something to be aware of. Updates on this will be landing very soon.

@fabiocav fabiocav added this to the Backlog milestone Oct 3, 2018
@gaikovoi
Copy link

gaikovoi commented Oct 4, 2018

#928 (comment)

@Joehannus
Copy link

Joehannus commented Oct 19, 2018

@fabiocav can you give an estimation on when the DI capabilities will be available in Azure Functions? We're using Boris Wilhelms implementation as well, and the startup entry no longer being added to the extensions.json when publishing is a bit annoying. Being able to use an out of the box solution for DI would be preferable therefore.

@DavidJFowler
Copy link

DavidJFowler commented Nov 15, 2018

There is a workaround for this issues posted in a different thread: Azure/azure-functions-host#3386 (comment)

This workaround no longer works with Microsoft.NET.Sdk.Functions 1.0.24 and netcoreapp2.1 function apps. An empty extensions.json file is generated.

I found another workaround - If the startup class is contained contained in a separate assembly referenced by the azure function assembly then the extensions.json is created correctly.

@gaikovoi
Copy link

@stijnbrouwers
Copy link

For me the extensions.json is empty as well using Microsoft.NET.Sdk.Function 1.0.24, netcoreapp2.1 and building with VS2017. Putting the startup class in a separate assembly didn't work for me. My workaround is to add the extensions.json file manually in my project and setting property 'Copy to Output Directory' to 'Copy if newer'.
image

@zmarty
Copy link

zmarty commented Dec 5, 2018

@fabiocav Feel free to reach out to me by internal Microsoft chat and I can show you how it fails live. And we are not using anything fragile, just straight Azure Functions.

@eastmane
Copy link

eastmane commented Dec 6, 2018

I seem to be able to reproduce this reliably (happy to share if required). Targetting netcoreapp2.1 extensions.json is empty, changing project to target netstandard2.0 it's created correctly. The fix suggested by @stijnbrouwers works for me but the workaround in #3386 doesn't.

Initial testing shows this is also the case targetting netcoreapp2.2.

@fabiocav
Copy link
Member

fabiocav commented Dec 6, 2018

Thank you for all the feedback here. The issue is well understood, but unfortunately, due to higher priority items (including design and implementation work on the official extensibility and DI model for Functions), it hasn't been addressed yet. We'll keep updating this as progress is made and will have this assigned to a sprint milestone when the work is assigned.

@jeffhollan
Copy link
Contributor

We're working on this now and work is being tracked here. I'm going to close this issue just so we don't have too many duplicate issues across repos. Progress is being made though (was on a few emails about progress today 😄)

Azure/azure-functions-host#3736

@wtt235-bh
Copy link

This appears to be an issue again now that V3 of the function runtime has been recently promoted out of preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests