azure-functions-host: .NET Core 2.2.1 + EF Core 2.2.1 causes load errors
- Function App version (1.0 or 2.0): 2
Repro steps
Create a jobs project in vs.net and link it to an EF Core Data Class library that has a context that implements IdentityContext.
Get a context in your function something like this:
var dbBuilder = new DbContextOptionsBuilder<dbCTxName>();
var dbOptions = dbBuilder.UseLoggerFactory(loggerFactory).UseSqlServer(configuration["ConnectionStrings:DBName"], x =>
{
x.EnableRetryOnFailure(2);
}
).EnableSensitiveDataLogging((Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "development").ToLower() == "development")
.Options as DbContextOptions<dbCTxName>;
return new dbCTxName(dbOptions);
It will error on: var dbBuilder = new DbContextOptionsBuilder<dbCTxName>(); with a type loader error.
Expected behavior
Azure Functions and the function host should always just work no matter what version of .NET core you’re using and should always be synchronized with all updates of .NET Core that come out otherwise security issues could be left open for months (last time was over a month from 2.1 to 2.2!)
Actual behavior
With 2.2.0 of EF Core nuget packages this will work fine. With 2.2.1 this will throw a type loader error.
Known workarounds
Downgrading nuget packages to 2.2.0 instead of 2.2.1 fixes the issue but there are security issues in 2.2.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 30 (7 by maintainers)
I initially raised an issue over this in August last year, and given the recent update to allow proper DI in Azure Functions I thought I would give it a whirl and I was disappointed to see that the exact same issue persists 10 months later! I have updated my demo repro the demonstrates an MVC project working fine, and an Azure Functions project breaking when trying to use the same
IdentityDbContext
.Does anyone know if this will be resolved in ASP.NET Core 3?
We’ll continue to execute on the plans I mentioned for the initial mitigation steps, which will hopefully help alleviate the issue and improve communication, but exposing something like that, with an opt-in model, is something tangible and I’ll work on the plans on our side. This will require some time as there’s some coordination to be done across a few different teams, but once there’s something more concrete to share, I’ll open up the issues for tracking.
Yes that would certainly help.
However, just as asp. Net core previews are easily added to azure app services using the extension they have, the same should be possible for functions.
And, all of this stuff needs to be released and at least available 0 day with net core releases, public and preview. Then what you do with azure is up to azure and hopefully you’ll grace us with an extension for previews and to force 0 day public release without having to wait for standard staged rollout.
@JohnGalt1717 I’m being transparent about the current state of the platform. Today, those updates are not deployed to the underlying platform at the same time they are published. We’re working to reduce the time to adoption to what I stated above. We’ll continue to work on improving this, which includes improvements to communication and clear message from the runtime. I understand that this is not ideal, but I do have provide accurate information about how this works as it is something customers need to consider when adopting a managed platform.
From an App Services perspective, an update like that cannot be blasted to thousands of customers without proper validation and announcement. As an Azure service, we (App Services and Functions) follow strict deployment guidelines that, in addition to validation, include phased rollouts in different regions. Deploying those updates before customers have access to RTM bits for validation is problematic, as they would be hit with the new version in production before they have a chance to validate them.
If you want to be in full control and use the functions programming model, your option would be to build and deploy as a private site extension (using app service plan) or use one of our container hosting options.
@hjpsievert .NET Core updates will be posted in the announcements (https://github.com/Azure/app-service-announcements/issues).
We understand this should be improved, but again, I’m providing information on how things work today and how to avoid the issue that was reported here. I appreciate the patience as we work on improving this process.
Thanks all - seeing this in my repro’s as well. If using Entity Framework Core today go with 2.2.3. 2.2.4 causes issues during service registration in startup. Not sure why, but flagging this as it’s come in a lot over the last few weeks.
/cc @fabiocav
@fabiocav , we are getting this problem with EFCore 2.2.4 and NetCore 2.2. Rolling back EFCore to 2.2.1, the problem ends, but it is kind of annoying discover that.