0

Note: This issue is not duplicate despite the title reads similarly.

The following upstream signalR trigger function has been working well until we upgraded the NuGet packages to the latest versions.

[Function("OnConnected")]
[SignalROutput(HubName = "myhub")]
public async Task<SignalRMessageAction> OnConnectedAsync([SignalRTrigger("myhub", "connections", "connected")] SignalRInvocationContext invocationContext)
{
    // do some stuff
    return new(target!)
    {
        ConnectionId = invocationContext.ConnectionId,
        Arguments = new object[] { "something" }
    };
}

The issue is that we started getting the following runtime exception:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.OnConnected'. Microsoft.Azure.SignalR.Management: Could not load file or assembly 'Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. We inspected the NuGet package references and found that we are not referencing Microsoft.Azure.SignalR.Management in our packages list.

Repro steps

Create an upstream signalR function in a .NET 7.0 dotnet-isolated v4 function app and add the following NuGet packages:

    <PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.14.1" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.10.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.SignalRService" Version="1.10.0" />

The dotnet version is 7.0.304

What is the workaround or fix for this roadblock?

Arash
  • 3,628
  • 5
  • 46
  • 70

2 Answers2

0

Could not load file or assembly 'Microsoft.Extensions.Options, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified

This error could be because of the upgradation of .NET version to 7.0.

To resolve this issue:

  • Need to check if all the installed dependencies version compatible with the .NET version. It can be checked in nuget.org.

  • Upgrade the package versions to its latest version which are compatible with the application's .NET version.

  • Also check by Installing the below nuget packages through Nuget Package Manager:

Microsoft.Extensions.Options
Microsoft.Azure.SignalR.Management

enter image description here

.csproj:

<ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.14.1" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.12" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.SignalRService" Version="1.2.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.10.0" />
    <PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.21.4" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.2.0" />
    <PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
  </ItemGroup>

References:

Refer to similar Github code given by Y-Sindo.

Pravallika KV
  • 2,415
  • 2
  • 2
  • 7
  • Unfortunately there’s an underlying issue with the budget pasckages per this GitHub issue https://github.com/Azure/azure-webjobs-sdk/issues/2993 – Arash Jul 02 '23 at 09:45
0

This issue will be fixed once Microsoft addresses this GitHub issue.

At this moment, I had to downgrade the NuGet packages.

Arash
  • 3,628
  • 5
  • 46
  • 70