25

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?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
geojoe
  • 329
  • 1
  • 3
  • 12
  • Could you please provide the .csproj package references file ? – Sairam Tadepalli Jul 19 '22 at 10:22
  • Having the same issue. @SairamTadepalli-MT this error is from Azure Functions Core Tools, not the posters project. – Victorio Berra Jul 20 '22 at 00: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 Jul 20 '22 at 07:58

13 Answers13

47

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

Rebuild solution.

ZackKnight
  • 586
  • 3
  • 4
16

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'"

Kevin Able
  • 301
  • 3
  • 5
  • 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 Apr 17 '23 at 13:34
  • 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 Kulkarni - Dhepe May 23 '23 at 09:46
13

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.

Victorio Berra
  • 2,760
  • 2
  • 28
  • 53
  • 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 Oct 03 '22 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 Sep 02 '23 at 15:48
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.

Jacob Rastad
  • 1,153
  • 10
  • 24
Thom Selö
  • 31
  • 2
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.

Tim Nguyen
  • 21
  • 2
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.

geojoe
  • 329
  • 1
  • 3
  • 12
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

Alex F.
  • 65
  • 6
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`
  • 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 Sep 16 '22 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. – Aaron McDavid Sep 17 '22 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 Sep 18 '22 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)

Mocas
  • 1,403
  • 13
  • 20
1

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

bau
  • 123
  • 1
  • 1
  • 7
1

I have simply updated the vs option below the image:

enter image description here

This update has solved my problem.

  • 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! – Brian Jun 24 '23 at 04:26
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).

BrianLe
  • 212
  • 3
  • 8
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

MAO
  • 99
  • 2
  • 16