Rahul Sharma
Rahul Sharma

Reputation: 337

Could not load file or assembly 'System.IdentityModel.Tokens.Jwt Azure function python

I have a python azure function app.

It was working fine, until this morning. func start runs fine, but when I run the listed endpoints, it throws this error:

An unhandled host error has occurred.
[2024-09-16T16:15:59.570Z] System.Private.CoreLib: Exception has been 
thrown by the target of an invocation. 
Microsoft.AspNetCore.Authentication.JwtBearer: Could not load file or 
assembly 'System.IdentityModel.Tokens.Jwt, Version=6.35.0.0, 
Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find 
the file specified.

I don't understand this at all. I have no reference to this package, neither am I using dotnet.

All I am using is Azure function core tools.

How do I fix this ?

Upvotes: 0

Views: 123

Answers (1)

Rahul Sharma
Rahul Sharma

Reputation: 337

I Solved this issue with the following steps:

  1. Check number of azure function core tools in your system and uninstall them.
  2. Uninstall dotnet sdk.
  3. Restart system.
  4. Install azure function core tools again.

Error did mention there was a file called System.IdentityModel.Tokens.Jwt, which was not present.

Issue was 2 versions of azure function core tools were installed. Path variable was using one and System.IdentityModel.Tokens.Jwt file in azure function core tools was of the other version.

Going clean slate did the job.

Thank you everyone for your help!

Upvotes: 0

Related Questions