30

I'm working in a virtual environment in VS Code and I can't understand why I'm getting this error:

[2022-07-19T10:00:31.580Z] A host error has occurred during startup operation '609dfded-e9f5-4fc4-b3a3-554bde11a415'.
[2022-07-19T10:00:31.582Z] Microsoft.Azure.WebJobs.Extensions.Http: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
Value cannot be null. (Parameter 'provider')

What should I check?

3
  • Could you please provide the .csproj package references file ? Commented Jul 19, 2022 at 10:22
  • Having the same issue. @SairamTadepalli-MT this error is from Azure Functions Core Tools, not the posters project. Commented Jul 20, 2022 at 0:08
  • @VictorioBerra For me, my Windows Defender was the issue. I was unable to execute pip.exe or func.exe. What I would recommend is excluding the entire path to your Azure Function Core Tools. Once you've done that, reinstall Azure Function Core Tools v4.
    – geojoe
    Commented Jul 20, 2022 at 7:58

14 Answers 14

48

Rolled back nuget package Microsoft.NET.Sdk.Functions from 4.1.3 to 4.1.1 on the Azure functions Api project.

Rebuild solution.

6
  • this worked for me thanks! looks like sth is wrong with 4.1.3 and even 4.1.2
    – alital
    Commented Sep 6, 2022 at 16:53
  • 1
    Thanks, this worked for me. Running via VS for mac on Apple M1
    – David
    Commented Sep 8, 2022 at 8:52
  • This was the only current solution I found that got it working while running in docker
    – IQn
    Commented Oct 3, 2022 at 10:21
  • The only thing that worked for me...lifesafever! Commented Oct 27, 2022 at 13:44
  • 1
    I had to also roll back the version of Microsoft.Azure.WebJobs.Extensions.Http to 3.0.12 because the latest version is incompatible Commented Nov 11, 2022 at 21:57
22

This fixed it for me, hope it helps someone else

  • Close Visual Studio
  • Delete folder C:\Users***\AppData\Local\AzureFunctionsTools
  • Restart Visual Studio.
  • Launch Application, folder gets recreated.

Taken from Unable to upgrade Azure Functions Core Tools, Exception "Cannot create instance of type 'NuGet.Versioning.VersionRange'"

3
  • That resolved the issue for me, previously I was downgrading the nuget package verison but I got tired of that and now it seems fine! Thank you!
    – iBobb
    Commented Apr 17, 2023 at 13:34
  • <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.2" /> This was 4.1.3 before, I downgraded this package to 4.1.2 but not worked. Your provided solution worked very well with 4.1.3
    – Pallavi D
    Commented May 23, 2023 at 9:46
  • strangely enough, a few month's back this solution didn't work for me, zackknight's solution to downgrade worked. But this time the downgrade did not work, and just deleting the AzureFunctionTool folder worked. Commented Mar 5 at 16:42
14

I had this issues as well, and my solution was to re-download and re-install the Azure Function Core Tools. I think installing twice fixed the issue for me.

3
  • 1
    I also got it running locally by updating the Tools, but this solution did not fix the issue while running in docker, onlt downgration Microsoft.NET.Sdk.Functions to 4.1.1 did.
    – IQn
    Commented Oct 3, 2022 at 10:23
  • Re-installing Azure Function Core Tools worked for me. I had v4.04x installed and was getting the error when trying to func start a brand new Function. Upgraded to AFCT v4.0.5312 and the problem ceased.
    – SeaDude
    Commented Sep 2, 2023 at 15:48
  • Recently I was migrating an Azure NodeJS function from v3 to v4 and I ran into this problem. Reinstalling the Azure Function Core Tools worked for me.
    – Matt
    Commented Oct 18, 2023 at 16:33
7

I have simply updated the vs option below the image:

enter image description here

This update has solved my problem.

3
  • Confirmed, worked for me. Was helping a colleague to setup a local dev environment for a solution which included Azure Functions. We upgraded his Visual Studio from 17.3 to 17.6, but received the error for this SO thread. This solution resolved, quite easily I might add. Sometimes the best answers are on the bottom! Commented Jun 24, 2023 at 4:26
  • 1
    Thankyou! This solved the following error for me: Microsoft.Azure.WebJobs.Extensions.CosmosDB: Could not load type 'Microsoft.Azure.WebJobs.ParameterBindingData' from assembly 'Microsoft.Azure.WebJobs, Version=3.0.34.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
    – Sam Jones
    Commented Sep 29, 2023 at 10:12
  • Did not resolve my problem. Microsoft.Azure.WebJobs.Extensions.Http: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
    – Meekohi
    Commented Jul 3 at 16:49
3

We encountered a similar problem after updating Microsoft.Azure.WebJobs.Extensions.Http to 3.2.0 Developers using Rider had no problems but no Visual Studio users could run our project.

This post explained it for us: https://weblogs.asp.net/sfeldman/updating-azure-functions-tools. Just by creating a new azure functions project, the latest version for AzureFunctionsTools was downloaded to \AppData\Local\AzureFunctionsTools.

Then we could run the project without errors.

3

In my case i just executed this command in my vs code project where the tool i would use was the v4 :npm install -g azure-functions-core-tools@4 --unsafe-perm true

1
  • This solution works for my Mac VSCode.
    – Kiry
    Commented May 3 at 3:13
2

For me, relaunching Azure Functions Core Tools installer and choose repair fixed the issue. I had been encountering this issue in the last two days and it's really annoying.

1

My solution to this issue was to go into Windows Defender and exclude:

C:\Program Files\Microsoft\Azure Functions Core Tools\func.exe

I then reinstalled Azure Functions Core Tools v4 and everything worked as intended.

Ps. After excluding make sure to give time for your system to update. I restarted and all worked as intended. Hope this helps someone.

2
  • 1
    I am not sure excluding was the solution more like re-installing the core tools, never excluded anything in defender myself Commented Aug 10, 2022 at 7:56
  • Installing and re installing azure func core tools fixes the issue Commented Jan 26, 2023 at 12:29
1

I had this exact issue until Yesterday when I tried updating Azure Function Core Tools (https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash) That resolved the problem, and I now am able to run my function's project using the CLI

1

I believe the cause is that the Azure Functions Core Tools (henceforth AFCT) that Visual Studio (or VS Code) uses does not have the proper version of Microsoft.Azure.WebJobs.Extensions.Http.dll. Installing AFCT doesn't affect anything directly, because VS uses its own version stored elsewhere. My strategy was to install the latest AFCT version and point VS to that new version.

These instructions are for x64 Windows.

  1. Install latest Azure Functions Core Tools
  2. Using the below PowerShell code, move VS's old version of AFCT, then point VS to the newly installed version

Move old AFCT, point VS at new version

# Find Afct in Program Files
$PfMicrosoftPath = Join-Path -Path $env:ProgramFiles -ChildPath 'Microsoft'
$AfctPath = Join-Path -Path $PfMicrosoftPath -ChildPath 'Azure Functions Core Tools'

# Find the latest Aft in your Local AppData
$VsAftPath = Join-Path -Path $env:LOCALAPPDATA -ChildPath 'AzureFunctionsTools'
$VsAftReleasePath = Join-Path -Path $VsAftPath -ChildPath 'Releases'
$VsLatestAfctPath = Get-ChildItem -Path $VsAftReleasePath | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName
$VsAfctCliPath = Join-Path -Path $VsLatestAfctPath -ChildPath 'cli_x64'
$VsAfctBackupPath = Join-Path -Path $VsLatestAfctPath -ChildPath 'cli_x64_backup'

# Move the existing AFCT and create a symlink
Move-Item -Path $VsAfctCliPath -Destination $VsAfctBackupPath -Confirm:$true    
New-Item -Type Junction -Path $VsAfctClipath -Target $AfctPath`
3
  • 1
    Great, I followed your advice and now it doesn't work... it deleted the folder cli_x64 inside release 4.13.0 and I can't find a way to install it again.
    – II ARROWS
    Commented Sep 16, 2022 at 13:56
  • I really should have thought have that possibility. I've changed the code so that it only moves the folder. In your AzureFunctionsTools folder, there is a feed-v#######.json file (use the latest if multiple), that shows you how it downloaded what's there. For example, the latest mine had downloaded was: https://functionscdn.azureedge.net/public/4.0.4775/Azure.Functions.Cli.min.win-x64.4.0.4775.zip You can re-download your most recently downloaded Core Tools and replace the symlinked folder with that version. Commented Sep 17, 2022 at 15:08
  • Nah, it didn't work. Even uninstalling and reinstalling the tools. I had to delete the whole AppData/Local/AzureFunctionTools folder and reinstalling, then cleaning the solution and starting it, which recreated the folder.
    – II ARROWS
    Commented Sep 18, 2022 at 16:05
1

The accepted answer didn't totally fix the issue for me, but I did find that the package Microsoft.NET.Sdk.Functions(4.1.3) does cause the issue, but I found another one does as well, so it will depend on what other packages you have in your app.

So, start with downgrading that package to (4.1.1), if that doesn't fix the issue, downgrade all packages and upgrade them one by one and try running the app after each upgrade. In my case the other package that was causing the issue along with the above package was Microsoft.Extensions.Http.Polly(7.0.0), the highest that worked for me was (6.0.11)

1

The accepted and other answers did not work for me.

SOLUTION

The solution for me was to delete the whole dependencies folder in "C:\Users{your name}.azurelogicapps\dependencies" Then when you restart visual studio code, the extension should automatically install the latest dependencies.

ISSUE EXPLANATION

The issue was caused by having an older version of Azure Function Tools, but when I executed the "func --version", it gave me the latest version. I had two installations on my PC.

My visual studio code extension went to another function core Tools installation located in "C:\Users{your name}.azurelogicapps\dependencies\FuncCoreTools\func.exe". I checked this version:

  • by right clicking on the func.exe file
  • properties -> details

Here I found the older version that was executed when I ran my application.

I tried editing it in visual studio code by:

  • file -> preferences -> settings -> extensions -> logic app standard and alter the file path for the dependencies to go to the "C:\Program Files\Microsoft\Azure Functions Core Tools\func.exe" version which was the latest version.

That didn't work, deleting the dependencies folder did.

2
  • 1
    So, did it work out in the end or not? If not, please don't post this as an answer
    – Nico Haase
    Commented Jan 9 at 10:51
  • 1
    @NicoHaase Thanks for your feedback, I structured the answer better now so it's more readable.
    – RensB
    Commented Jan 10 at 8:42
0

You can check your machine and use the latest version of azure-functions-coretools. For those are using Rider, go to settings > tools > Azure > Functions > Upgrade your tools to latest one (the version 4.0.4785 fixed my issue).

0

Probably not the correct/enterprise way to fix this but I got it working by backing up the contents of folder

C:\Users{name}\AppData\Local\AzureFunctionsTools\Releases\4.32.0\cli_x64

And replacing with the contents of

C:\Program Files\Microsoft\Azure Functions Core Tools

Restarted VS, cleaned and re ran the solution and worked straight away.

Pls note this was for a personal project, I'm an ex full time/pro coder and this was just causing me a headache.

I can't guarantee it will work for all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.