I have an API and a separate Azure Functions app. I upgraded my API app to .NET 5 and it's working fine. In the API app's solution, I have class library projects that I also reference in my Azure Functions app. These class libraries are netstandard2.1 projects.
Ever since this update -- during which I also updated all my NuGet packages to latest versions -- my Azure Functions app stopped working. I'm getting the following error:
Could not load file or assembly
'Microsoft.Extensions.Configuration.Abstractions, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot
find the file specified. Value cannot be null. (Parameter 'provider')
I noticed that there were breaking changes involving the Microsoft.Extensions.* packages and their recommendation is to install the package that is causing the issue directly. So I added Microsoft.Extensions.Configuration.Abstractions to my Azure Functions manually -- before it was being installed as a dependency of Microsoft.Extensions.Configuration package. Here's the information about this:
https://github.com/dotnet/aspnetcore/issues/21033
The issue still persists. I even tried downgrading Microsoft.Extensions.Configuration in both the API and Functions app, but I'm still getting the same error.
Any idea how to resolve this issue?
Sam's comment should be accepted as correct answer. I try it out to downgrade Microsoft.Extensions* (in my case Microsoft.Extensions.Logging.Console) from 5.0.0 to 3.1.0 and the error just gone.
Bravo!
If you are upgrading from .NET Core 3.1 to .NET 6 and you get this error, you need to change the Azure functions version to v4 and it fixes this error.
As a reference, this GitHub link explains exactly why that happens.
And as of now, you either track down the exact versions been referenced or downgrade everything to the latest v3 build.
In a nutshell, Azure Functions SDK already has some dependencies loaded in memory, so your libraries cannot use newer versions of the same libraries.
Adding this answer in case it helps anyone upgrading from .NET 3.1 to .NET 6.0.
First, as per #Jeff's answer, make sure you reference v4 in the Azure Functions project .csproj file:
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
In my case, however, this was already set.
The Azure Function was running fine locally however in Azure DevOps pipeline I was getting the error described by the OP.
I noticed that when debugging the Azure Function locally, the console was outputting:
Azure Functions Core Tools
Core Tools Version: 4.0.3928 Commit hash: 7d1d4a32700695bbf290a871c7492fde84bb767e (64-bit)
Function Runtime Version: 4.0.1.16815
In my case I am actually running the Azure Function in an Azure DevOps pipeline for e2e test purposes. To achieve this, I first install the Azure Function Core Tools on the build agent using this npm command:
npm install azure-functions-core-tools -g
However this installs azure-functions-core-tools#3.0.3904 (version 3.x - NOT the latest version 4.x).
I then installed Azure Function Core Tools (v4), e.g. by installing with this npm command.
npm i -g azure-functions-core-tools#4 --unsafe-perm true
And this (for me) resolved the error.
Whether or not this is your exact scenario, make sure you are using Azure Function Core Tools v4.x if using Azure Function Runtime v4 and .NET 6.
As #binaryDi mentioned in their answer, you need to downgrade packages that reference version 5 of Microsoft.Extensions.Configuration.Abstractions.
This can be a bit of a pain, as it doesn't tell you which packages are actually referencing Microsoft.Extensions.Configuration.Abstractions package/namespace.
For me, I had to update Microsoft.Extensions.Caching.Memory and Microsoft.EntityFrameworkCore.SqlServer to a version before 5. Anything that is referencing dotnet 5 should be downgraded for the Azure Function to run.
I stumbled upon this question while looking for an answer to my problem with upgrading to .NET 6.0. There was no going back, because I've bought a Macbook with an M1 processor and Arm support only works decently in .NET 6.0
Putting <AzureFunctionsVersion>v4</AzureFunctionsVersion> wasn't enough, because that doesn't increase the runtime version on Azure.
My function was already running on version 3.0 and strangely I couldn't select v4.0 in the portal. I had to change the version through the Azure CLI.
More information on how to do that can be found here: https://learn.microsoft.com/en-us/azure/azure-functions/set-runtime-version?tabs=azurecli
I also ran into this error when upgrading a c# function project from NETCORE 3.1 to .NET 6.
I set the following in the project (.csproj).
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
AND also changed the Application setting value in the Function App - Configuration Section (Azure Portal)
"FUNCTIONS_EXTENSION_VERSION" from "~3" to "~4"
and that fixed it for me.
I also ran into this error when upgrading a c# func project from version 3 to 4.
I had already set <AzureFunctionsVersion>v4</AzureFunctionsVersion> but that didn't solve it.
The answer by #neeohw pointed me to the solution that fixed it for me, but I had to dig a bit further, and this is what fixed it for me:
Do the Azure cli commands as specified here:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=in-process%2Cv4&pivots=programming-language-csharp#azure
I suggest you read that section for a background understanding, but the commands that ran was these:
az functionapp config appsettings set --settings FUNCTIONS_EXTENSION_VERSION=~4 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>
# For Windows function apps only, also enable .NET 6.0 that is needed by the runtime az functionapp config set --net-framework-version v6.0 -n <APP_NAME> -g <RESOURCE_GROUP_NAME>
The issue was occurring to me, when I was trying to host an upgraded function in Azure functions. The previous version was targeted to netcoreapp3.1, which I upgraded to target net6.0 and, set v4 as Azure Function version.
The error was
"Could not load file or assembly 'Microsoft.Extensions.Configuration', Version=6.0.0.0 in Azure Functions"
After spending couple of hours, I figured that its the startup class that was causing the issue because it was the only place Configuration was used.
Changing the Startup to inherit from FunctionsStartup rather than WebJobsStartup, fixed the issue.
And with slight adjustments, it worked.
[assembly: FunctionsStartup(typeof(Startup))]
...
public class Startup : FunctionsStartup { ...
public override void Configure(IFunctionsHostBuilder builder)
{
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddHttpClient();
...
}
That's it!
I had the same issue and the configuration for Azure FunctionsVersion was already present.
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
I was able to resolve the issue by downgrading the version of Microsoft.Extensions.Http from 7 to 6
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
I was this error on my Mac (arm) when I tried to ran my functions (.NET6) locally.
In my case, I tried your solution and the functions still would not start and I still had this log in the console: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified..
I realized that I had installed 2 instances of azure tools (v3 with HomeBrew and v4 with npm).
When I run func start to start my functions, I observed that v3 was used. So I uninstalled the v3 tools with HomeBrew to use v4 with npm).
In my case, the reason was Microsoft.EntityFrameworkCore version 5.0.2.
I donwgraded it to version 3.1.18.
(Other related packages, such as Microsoft.EntityFrameworkCore.Design, Microsoft.EntityFrameworkCore.SqlServer, and Microsoft.EntityFrameworkCore.Tools should also be downgraded to 3.1.18.
I had this error when I used the latest of version Npgsql.EntityFrameworkCore.PostgreSQL which is 5.0.7 as this time of writing. I had to downgrade to 3.1.11 for the current version has a dependency to the 5.0.0.0 version of
Microsoft.Extensions.Configuration.Abstractions.
I'm a beginner in RavenDB, but I can't seem to get started. I'm getting stuck at loading an entity in C#.
I am getting a null exception error.
Below is my screenshot for the exception:
And in my RavenDB studio, it looks like this:
So, I'm totally stuck now.
I am very sure i have done everything else right.
The client has connected to the server with correct Url, the DefaultDatabase is correct, and the session.Load parameter is correct id
Hope someone can help :-)
Make sure that versions of server package and client nuget match. In your code, you use Url and DefaultDatabase for DocumentStore, both of which were changed a long time ago (May 2017) to Urls and Database.
It is very likely that you use an outdated client package. Install the client package for matching version of RavenDB using Package Manager Console in Visual Studio using a command like this:
Install-Package RavenDB.Client -Version 4.0.0-nightly-20180123-0500 -Source https://www.myget.org/F/ravendb/api/v3/index.json
This command is for the latest nightly version, you want to use -Version matching the server you are running.
Find the appropriate version here: https://ravendb.net/download
I have a nice application where I'm using Telerik's Kendo UI for Angular 2. It is getting better and better. I would like to setup my builds in VSTS where installing packages, compiling TypeScript files are part of the build. Getting packages from Telerik repository requires authentication. I haven't found so far any usable description how to do it.
Telerik says that I should either directly authenticate or use .npmrc file and refers to an MS site.
The funny thing is that npm login (which is needed to connect Telerik's npm repo) does not accept username and password as parameter (doesn't matter how the community screams for it). I don't know why Telerik refers to this.
The .npmrc option is also funny, because it says that I should use vsts-npm-auth package to get credentials. I assume it means that I'll get the credentials of the build machine and it will be written in .npmr file. It is not a good solution for me. I got the build machines from a pool and the credentials rather a strongly limited credentials (enough fora build machine and nothing more) which does not equal my username and password at Telerik.
So, that's where my story ends and I need some help from you guys. How to do it? Did I misunderstand something? Is there anybody out there who did it?
First, vsts-npm-auth is used for VSTS.
Secondly, after logging in (npm login) the .npmrc will be populated with an authentication token that can be copied to build agents or store file per-project. So try to use this .npmrc file and check the result.
It figured out that vsts-npm-auth doesn't work together other private repositories than VSTS feeds. I let the team know and they, hopefully, will implement it.
I'm trying to setup a CI server for a website that I'm developing, but I can't find any info regarding how to do it with the new ASP.NET 5.
I got you brother. This took me a few days to figure out. This configuration is on TeamCity v10 for a ASP.NET Core 1.0 RC2/preview2 project. As a bonus, I am including the step where it pushes to Octopus Deploy. You will need to install the dotnet teamcity plugin and the newest Octopus Deploy plugin with Push functionality. Here's an overview of the build steps:
First off, don't try to use dotnet restore to restore the packages. It won't work if you have internal nuget packages that are not compiled as .Net Core. This took forever to figure out. I would ignore trying to use dotnet restore until people have converted everything over to .Net Core or Microsoft fixes dotnet.exe to be more flexible.
Some of the stuff I read said to use the newest beta version of NuGet, 3.5. When I tried this, I would get the following error.
[14:30:09][restore] Starting NuGet.exe 3.5.0.1737 from D:\buildAgent\tools\NuGet.CommandLine.3.5.0-rc1\tools\NuGet.exe
[14:30:10][restore] Could not load type 'NuGet.CommandAttribute' from assembly 'NuGet, Version=3.5.0.1737, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I don't know what that means, and I don't care. Use 3.4.4 for now. Fill in the rest as appropriate.
The dotnet publish step is pretty straightforward. Make sure you provide the output directory because you want to use it in the final step. Also, be sure to specify an absolute path by using the %teamcity.build.workingDir% variable because of this bug. Otherwise it will fail to find your web.config file and not finish publishing the entire site. You'll be missing things like web.config and wwwroot!
Finally we Push to Octopus. This was very tricky for me. Note the part that says
%teamcity.build.workingDir%/published-app/**/* => OrderReviewBoard.1.0.0.zip
IF ANY PART OF THIS IS INVALID, YOUR STEP WILL FAIL WITHOUT EXPLAINING ITSELF!!! By invalid, I mean maybe you put a teamcity environment variable (like the %build.number% they show in all the examples) in that zip name that doesn't properly resolve. Or you specify a non-existent path. Or any number of things, you will see an error that says "[Octopus Deploy] Please specify a package to push". That means that one was never generated because that statement failed. I realize you want to have an auto-incrementing build number there. I'll leave it up to you to figure out how to do that.
Don't get all confused by what is running here. Octopus tries to explain it on their site, but it is hidden here. There is octo pack and octo push. The new version of octo pack is running out of sight, based on whatever statement you put in that "Package paths" box. Don't get sidetracked trying to create a nuspec package, or trying to use dotnet pack. These are dead ends for our purposes. Create a .zip file and move on with your life. Finally, notice the additional command line arguments I added. These help you out a tiny bit. They aren't required. Good luck.
We (the ASP.NET team) use TeamCity as the build server. Each repo has a build.cmd file, similar to this one. TeamCity simply invokes that file.
For Mac/Linux builds, there is a build.sh file.
At the moment you can try to use TeamCity plugin for .NET Core projects:
https://github.com/JetBrains/teamcity-dotnet-plugin
Please check these blog posts;
http://blog.coderinserepeat.com/2015/01/25/building-asp-net-5-projects-in-teamcity/
http://blog.maartenballiauw.be/post/2014/12/19/Building-future-NET-projects-is-quite-pleasant.aspx
Since there has been many changes to the ASP.NET Core world and I got asked about it a few times, I wrote down a step-by-step guide on how to setup a CI/CD environment using TeamCity for .NET Core. I think it is especially helpful for beginners.
I have an MVC App which uses Azure AD, it works very well using the WindowsAzure.AD.Graph.2013_04_05 helper project that Microsoft made available. This project is now outdated, but looking at the new Nuget Package, the two require code changes.
I have two questions, How long can I use the old one before I find myself locked out of my own app. Second, has anyone migrated between them?
What I have is very simple, its just an Auth Filter which checks if a user is in one or more groups.
You should have at least a year from the announcement of a REST version being deprecated; a REST version is not the same as a NuGet package version, so you'll need to understand the underlying version in use.
Please refer to this Microsoft support policy on Azure-related REST APIs and libraries: http://support.microsoft.com/gp/azure-cloud-lifecycle-faq