-
Notifications
You must be signed in to change notification settings - Fork 447
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
FunctionsStartup not being called after runtime update in Azure, causing DI failure #5401
Comments
After another round of troubleshooting, I've determined that I'm experiencing this exact issue: Azure/Azure-Functions#972 The only way I was able to get the functions running was to use the workarounds in both of the following comments: #3386 (comment) Adding Directory.Build.targets didn't work on its own and manually adding extensions.json also didn't work on its own, but together I get the proper extensions.json in the publish folder: C:\Projects\MyApp\MyApp.Functions\obj\Release\netcoreapp3.1\win-x64\PubTmp\Out\bin I'm not going to bother opening another issue, but in case anyone reads this, I get OutOfMemoryExceptions after every publish which magically seems to resolve itself after about 30 minutes. It made troubleshooting this issue a true nightmare, and honestly this whole experience makes Azure Functions feel like an early beta / toy. I'm glad this is for a personal project as I'll be avoiding functions like the plague from here on out. This issue is the worst of the ones I've run into, but it's not nearly the first. The idea is cool, but I'll check back in a year or two when it's hopefully ready for production. |
Hello
from host.json file to make Startup class be called again. |
And that's in the built solution, correct? |
Yes, i've checked file history, and it was created by Visual Studio Code's Azure Function extension. |
@soninaren this seems like an issue with the bundles selection process and the templates, which shouldn't apply to pre-compiled scenarios. @Ludogo can you confirm the steps you've followed to create the Function project? |
I created a new C# precompiled project via VS Code, the host.json did not have bundle configuration in it. I tried adding several templates to it as well to make sure any additional action does not change host.json configuration. @Ludogo let us know if you have the repro steps for project creation. |
I got the same issue as well. The workaround was to downgrade |
I'm still having this problem - where the extensionBundle property in the host.json file is being populated incorrectly.
To test, I've placed a breakpoint in the |
@wtt235-bh based on the logs above (thank you for sharing!), it looks like you may have extension bundles configured, which would cause the issue you're describing. Please remove the extension bundles configuration in |
The Just in case this is important - my installation of visual studio is updated to the latest version. |
@wtt235-bh somehow, it does seem like that has been added to your |
Rebuilding the solution an manually removing the "extensionBundle" property before running the debugger allows the Startup class to execute. Just to clarify something I said earlier, the global host.json file doesn't initially exist until after running the function app locally. So I have to run it, then modify the host.json file, the run it again to get it to work. |
Explicitly adding a host.json file to your solution (and set its property to copy to the output folder) should address this issue. @soninaren a new issue should be created to track this specific scenario with pre-compiled functions. |
That works. After manually adding a global host.json file (with no extensionBundle), the startup executes. |
I already had a global host.json file with no extensionBundle and it was still failing. This is what fixed for me:
|
@VitorRigoni looks like your issue was slightly different and you had a reference to 3.x when running on 2.0 |
@fabiocav I'm having the same issue, when you say "running on 2.0" which value are you referring to ?
I also created
Downgrading |
@leboeuf that was specifically about what @VitorRigoni was reporting above. The version in Do you have the same issue mentioned above where the extension bundle configuration is defined in your |
@fabiocav I do not have an extension bundle in
Is the |
I got it working, my issue was that I was overwriting the configuration with this line:
This caused me to falsely believe that Startup wasn't called. I fixed it by removing the line and replacing it with something similar to #4464 (comment). |
@fabiocav i had followed documentation available at https://docs.microsoft.com/fr-fr/azure/azure-functions/functions-develop-vs-code?tabs=csharp on 23th october with the current version of function SDK at this time. |
@Ludogo so, to clarify, the updated version doesn't have that reference, correct? |
No it doesn't. So i've deleted extension bundle declaration and all works fine :) |
@fabiocav it worked for me after deleting extensionBundle, but I am seeing performance issues after deleting extensionBundle from host.json. This is working, but I am seeing performance issues. { |
I had this issue today with a brand new functions project, the
Downgrading |
Same thing just happened to me, no binding registration was found, I had to downgrade to 3.0.3 to have Startup.Configure(...) called again. |
I had the exact same issue as @benmiller86. I'm pretty sure 3.0.4 introduced a bug so FunctionsStartup/WebJobsStartup won't trigger any more. |
Same here, downgrading to 3.0.3 solved the issue for me. |
I can also confirm that it is an issue with Microsoft.NET.Sdk.Functions version 3.0.4. Issues was resolved once I downgraded back to 3.0.3 . |
I have experienced this issue and the downgrade from 3.0.4 to 3.0.3 also resolved it. |
Downgrading to 3.0.3 fixed our functions as well. Too bad I found this thread after solving and not 6 hours ago... |
* Update authorization-service-ci.yml * Update authorization-service-ci.yml * Reverting back to 3.0.3 Azure/azure-functions-host#5401 * Update authorization-service-ci.yml
@Alberto2686 Can you provide a working example project ? |
@StefH I can't at the moment but I can suggest 2 checks:
Let me know it this helps, otherwise I can provide you a repo tomorrow |
I've made a repo to reproduce @benmiller86 's bug. https://github.com/TroyWitthoeft/AzureFunctionsHostStartupBug If you clone that down and debug, you'll notice the Startup.cs is not hit. If we update the csproj file and change the Microsoft.NET.Sdk.Functions version from 3.04 to either 3.0.3 or 3.0.5, then the Startup.cs file is again hit. Project uses Functions v3, dotnet core 3.1 |
The SDK issue has been resolved in 3.0.5. If you’re running into a problem after moving to 3.0.4, please just upgrade. |
Does this apply for all types of Azure Functions? |
This is absolutely pathetic from Microsoft. How is it possible that one of the world's largest software companies managed to push an update that is completely, fundamentally broken in the simplest way possible? Do you not have any tests of any sort for this software? And why, for the love of all that is holy, have you not pulled the broken and useless 3.0.4 from NuGet? With a corresponding blog post to notify people to avoid that version? Or even an issue pinned on this repo? Unbelievable. Just unbelievable. |
@IanKemp I hear you. We burned some time on this bug too. It hurt. OTOH, this is a open source project. It's free. They accepts PRs. If you've got the talent, help them out and add some test coverage for this? We'd all benefit. |
That would require me to gift some of my own time to Microsoft. Considering that time is money, and that I've already paid for Azure, what you're effectively suggesting is that I pay Microsoft to write the tests that they, as a multibillion-dollar company, already should have in place as basic due diligence. Or to put it another way, Microsoft gets for free something they would normally have paid an employee for. You can probably guess how I feel about doing that. If we were talking about OSS from a nonprofit, my reaction would be quite different. But not only is this a for-profit company, and an extremely profitable one at that; we are literally paying for this functionality from said company. Open-source does not abrogate Microsoft of responsibility for basic quality, and it most certainly does not mean that we the paying end users should be willing to fall into the trap of doing Microsoft's work for it. |
@IanKemp This particular piece of functionality seems to break with every other release. I'm still using the workaround noted just below my original post because when I tried to take it out, I still couldn't manage to get my Startup method called. I share your frustration, because like you I'm paying a hefty Azure bill every month. I don't put Azure Functions in the same OSS league as I do something like MediatR where the author gets very little (nothing?) for the work. As it stands I have a few timer functions in production, but beyond that I'll check back on how this is doing in a year or two. |
I still get an error when running a V3 function on a Linux App Service. Anyone else noticed this same behaviour also? See also Azure/Azure-Functions#1518 |
@StefH if you're still seeing this issue with the latest version of the SDK, can you please open a separate issue with the details requested on the template so we can take a closer look? Closing this as the issue has been resolved in 3.0.5. Also tracking the work to create additional validation steps in the coming spring: Azure/azure-functions-vs-build-sdk#404 |
I had recently updated my Azure Functions from v3-preview to v3 after the .NET Core 3.1 GA announcement. Everything was running fine for development locally and in Azure.
At almost exactly 10:30PM EST on Friday (2019-12-13), all of my functions in development and production environments (two different resource groups) started failing.
Everything still runs fine locally.
The reason is that FunctionsStartup is no longer being run. I have no means by which to fix this as these functions were developed from day 1 in .NET Core 3 and have netcoreapp3.1 dependencies I can't change. I have no way to rollback these functions to v2.
My functions app on Azure reads:
Runtime version: 3.0.12939.0 (~3)
Local development reads:
Azure Functions Core Tools (3.0.2009 Commit hash: 77395527a4e9c28da8400dcfd1a450f4e0d0c36c)
Function Runtime Version: 3.0.12930.0
Let me reiterate - this was working after upgrading from v3-preview to v3. It stopped working after something was deployed by the Azure team
This is incredibly frustrating as a breaking changed was simply introduced by someone at Microsoft.
Investigative information
Please provide the following:
Repro steps
Register something in a DI Container like so:
Use it like so:
Expected behavior
Constructor injection works properly
Actual behavior
FunctionsStartup ignored, Greeter isn't registered in DI container, results in exception:
Unable to resolve service for type 'Greeter' while attempting to activate 'MyApp.MyFunction'. System.InvalidOperationException: at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService (Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at lambda_method (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
Known workarounds
#5401 (comment)
The text was updated successfully, but these errors were encountered: