Microsoft.Azure.WebJobs.Extensions.Http: Could not load file or assembly

Viewed 1379

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

Does anyone have any recommendations on what I should check?

Thanks

6 Answers

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.

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

Rebuild solution.

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.

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`

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.

Related