func CLI from Github releases and .NET Core 3.1 SDK> func --version3.0.2630> func init ImageService --dotnet> cd ImageService> func new -l C# Create new function with HTTP trigger> dotnet add package System.IdentityModel.Tokens.Jwtnamespace ImageService
{
public static class Hello
{
[FunctionName("Hello")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
ILogger log)
{
// Use nuget: System.IdentityModel.Tokens.Jwt
var handler = new JwtSecurityTokenHandler();
return new OkObjectResult("Hello");
}
}
}
> func startAnd we can hit the API endpoint and get 200 OK

Now, update nuget Microsoft.NET.Sdk.Functions to 3.0.9 and run func start again

We get an exception
Executed 'Hello' (Failed, Id=a85a430a-6936-4d0b-8db7-9f04365e893c)
[2020-08-06 6:25:05 PM] System.Private.CoreLib: Exception while executing function: Hello. ImageService: Could not load file or assembly 'System.IdentityModel.Tokens.Jwt, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
As per this comment, I understand we can use property <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> in *.csproj file however it feels more like a workaround and we would like a better solution
Experienced the same here
[12.08.2020 13:31:15] System.Private.CoreLib: Exception while executing function: System.Private.CoreLib: Unable to load one or more of the requested types.
[12.08.2020 13:31:15] System.Private.CoreLib: Exception while executing function: System.Private.CoreLib: Unable to load one or more of the requested types.
[12.08.2020 13:31:15] Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] e820aeb43c8645d5b0dd0cfd8e7a573c:0: Function 'AutomotiveLeadIndexing_StartAuditLog (Activity)' failed with an error. Reason: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
[12.08.2020 13:31:15] Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
[12.08.2020 13:31:15] at System.Reflection.RuntimeAssembly.get_DefinedTypes()
[12.08.2020 13:31:15] at Scrutor.TypeSourceSelector.<>c.<InternalFromAssemblies>b__20_0(Assembly asm)
[12.08.2020 13:31:15] at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
[12.08.2020 13:31:15] at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
[12.08.2020 13:31:15] at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
[12.08.2020 13:31:15] at Scrutor.LifetimeSelector.Scrutor.ISelector.Populate(IServiceCollection services, RegistrationStrategy strategy)
[12.08.2020 13:31:15] at Scrutor.ServiceTypeSelector.Scrutor.ISelector.Populate(IServiceCollection services, RegistrationStrategy registrationStrategy)
[12.08.2020 13:31:15] at Scrutor.ImplementationTypeSelector.Scrutor.ISelector.Populate(IServiceCollection services, RegistrationStrategy registrationStrategy)
[12.08.2020 13:31:15] at Scrutor.TypeSourceSelector.Populate(IServiceCollection services, RegistrationStrategy registrationStrategy)
[12.08.2020 13:31:15] at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.Populate(IServiceCollection services, ISelector selector, RegistrationStrategy registrationStrategy)
[12.08.2020 13:31:15] at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.Scan(IServiceCollection services, Action`1 action)
.. my proj stack...
[12.08.2020 13:31:15] at lambda_method(Closure , FunctionAutomotiveLeadIndexer , Object[] )
[12.08.2020 13:31:15] Host started (10730ms)
[12.08.2020 13:31:15] at Microsoft.Azure.WebJobs.Host.Executors.MethodInvokerWithReturnValue`2.InvokeAsync(TReflected instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\MethodInvokerWithReturnValue.cs:line 21
[12.08.2020 13:31:15] Job host started
[12.08.2020 13:31:15] at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync(Object instance, Object[] arguments) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs:line 52
[12.08.2020 13:31:15] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker, ParameterHelper parameterHelper, CancellationTokenSource timeoutTokenSource, CancellationTokenSource functionCancellationTokenSource, Boolean throwOnTimeout, TimeSpan timerInterval, IFunctionInstance instance) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 568
[12.08.2020 13:31:15] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 514
[12.08.2020 13:31:15] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, ParameterHelper parameterHelper, IFunctionOutputDefinition outputDefinition, ILogger logger, CancellationTokenSource functionCancellationTokenSource) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 460
[12.08.2020 13:31:15] at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance, FunctionStartedMessage message, FunctionInstanceLogEntry instanceLogEntry, ParameterHelper parameterHelper, ILogger logger, CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs:line 270
[12.08.2020 13:31:15] System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] File name: 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[12.08.2020 13:31:15] System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
[12.08.2020 13:31:15] File name: 'Microsoft.IdentityModel.Tokens, Version=6.7.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
I checked all versions below starting from 3.0.9 ending with 3.0.3. Version 3.0.3 seems to work fine.
Most helpful comment
As per this comment, I understand we can use property
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>in*.csprojfile however it feels more like a workaround and we would like a better solution