locked
Could not load file or assembly 'Microsoft.IdentityModel.Tokens' RRS feed

  • Question

  • User-1128090897 posted

    Hello,

    I'm trying to add the `Microsoft.Azure.WebJobs.Extensions.SignalRService` dependency to my existing Azure Functions v2 project. I'm trying to use the output function binding to send a message to my Azure SignalR service. I'm getting the following error. from the Function host on Windows, when trying to send a message, though ...

    ```
    Executed 'PublishLogMessage' (Failed, Id=95dfc2da-e0f1-4eef-bf50-2f6da1f94562, Duration=218ms)
    System.Private.CoreLib: Exception while executing function: PublishLogMessage. Microsoft.Azure.SignalR.Common: Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. System.Private.CoreLib: Could not load the specified file.
    Message processing error (Action=UserCallback, ClientId=MessageReceiver11ryan-publish-log-message, EntityPath=ryan-publish-log-message, Endpoint=wibradixdev.servicebus.windows.net)
    System.Private.CoreLib: Exception while executing function: PublishLogMessage. Microsoft.Azure.SignalR.Common: Could not load file or assembly 'Microsoft.IdentityModel.Tokens, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. System.Private.CoreLib: Could not load the specified file.
    ```

    Below is the code that I'm using to try to send the message ...

    ```csharp
    [FunctionName("PublishLogMessage")]
    public async Task RunAsync([ServiceBusTrigger("%PublishLogMessageQueue%", Connection = "AzureWebJobsServiceBus")] string message, [SignalR(HubName = "LogMessageHub")] IAsyncCollector<SignalRMessage> signalRMessages, ILogger log)
    {
    var messageData = JsonConvert.DeserializeObject<PublishLogMessageMessage>(message);

    log.LogInformation($"Querying log message data for id {messageData.LogMessageId} ...");

    var logMessage = await m_context.LogMessages.SingleAsync(m => m.Id == messageData.LogMessageId);

    log.LogInformation("Broadcasting message ...");

    var payload = new SignalRMessage
    {
    Target = "broadcastMessage",
    Arguments = new[] { "foo", "bar" }
    };

    await signalRMessages.AddAsync(payload);
    }
    ```

    And below are the various versions of my dependencies ...

    ```xml
    <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    </PropertyGroup>
    <ItemGroup>
    <PackageReference Include="CommonServiceLocator" Version="2.0.5" />
    <PackageReference Include="Google.Cloud.Vision.V1" Version="1.3.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.2.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.2.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.11" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="3.0.14" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.6" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.36" />
    <PackageReference Include="SixLabors.ImageSharp" Version="1.0.1" />
    </ItemGroup>
    ```

    So you can see it's a Functions v2 app - not yet upgraded to v3. We're on `netcoreapp2.2`, as well. We're on the 1.0.36 version of the Functions SDK.

    Any ideas what the issue might be, here?

    Thanks

    Tuesday, September 8, 2020 2:00 PM

All replies

  • User-1128090897 posted

    After some digging through other issues, I came across a few recommending adding the following line to the csproj file ...

    `<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>`

    That seems to resolve my issue.

    Tuesday, September 8, 2020 4:09 PM