Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrofitting Azure SignalR to Existing App Service #1693

Open
darena-patrick opened this issue Oct 6, 2022 · 6 comments
Open

Retrofitting Azure SignalR to Existing App Service #1693

darena-patrick opened this issue Oct 6, 2022 · 6 comments
Labels
pending-customer-confirmation Suggestions provided, waiting for the customer's confirmation

Comments

@darena-patrick
Copy link

darena-patrick commented Oct 6, 2022

Describe the bug

  • ✅ When publishing / deploying via Visual Studio Web Deploy, connecting the Azure SignalR Service Dependency works as expected.
  • ❌ When publishing / deploying via the dotnet publish command (via GitHub Actions CI/CD), the SignalR service does not properly connect to the app service.

To Reproduce

  • Create a sample Blazor project that leverages SignalR
  • Publish to Azure App Service via Visual Studio and create Service Dependency on an Azure SignalR service via the UI
    image
  • Without making any changes to the infrastructure, deploy via dotnet commandline and deploy to Azure App Service.
  • Errors will appear such as these:
    image
    image

Further technical details

  • Your Azure SignalR SDK version:
    <PackageReference Include="Microsoft.Azure.SignalR" Version="1.18.3" />

In the appsettings.json file:

"Azure": {
    "SignalR": {
      "Enabled": "true",
      "ConnectionString": "redacted"
    }
  }

Is there something extra that is needed besides adding the package reference to the project and adding the settings to appsettings.json that need to be done to accomplish this?

@darena-patrick
Copy link
Author

darena-patrick commented Oct 6, 2022

I did two apps side by side ... exact same binaries / configuration. In Kudu in Azure I ran the application via Debug Console.... here is the difference between the outputs:

The one published via Visual Studio:

info: Microsoft.Azure.SignalR.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://signalr-REDACTED.service.signalr.net/server/?hub=componenthub&cid=REDACTED'.
info: Microsoft.Azure.SignalR.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://signalr-REDACTED.service.signalr.net/server/?hub=componenthub&cid=REDACTED'.
info: Microsoft.Azure.SignalR.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://signalr-REDACTED.service.signalr.net/server/?hub=componenthub&cid=REDACTED'.
info: Microsoft.Azure.SignalR.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://signalr-REDACTED.service.signalr.net/server/?hub=componenthub&cid=REDACTED'.
info: Microsoft.Azure.SignalR.Connections.Client.Internal.WebSocketsTransport[1]
      Starting transport. Transfer mode: Binary. Url: 'wss://signalr-REDACTED.service.signalr.net/server/?hub=componenthub&cid=REDACTED'.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\home\site\wwwroot\
info: Microsoft.Azure.SignalR.StrongServiceConnectionContainer[1]
      Hub 'ComponentHub' is now connected to '(Primary)https://signalr-REDACTED.service.signalr.net(hub=ComponentHub)'.

The one published with dotnet publish

info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\home\site\wwwroot\

@darena-patrick
Copy link
Author

I did some detailed comparison of the side-by-side and found the only difference was that the Visual Studio version has an entry in web.config that was not in dotnet publish:

<environmentVariables>
  <environmentVariable name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="Microsoft.Azure.SignalR"/>
</environmentVariables>

The ridiculous thing is ... I also have this exact same variable in both application's Azure configuration:
image

So the question I have is ... why does it only work if it's manually in the web.config and not in the app service settings?

@Y-Sindo
Copy link
Member

Y-Sindo commented Oct 9, 2022

About the question why "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" environment variable doesn't work in App Service settings, App Service support is probably a better channel to go through.

@Swellenator
Copy link

I have this issue also. I have set these configuration values:

image

Yet it uses regular SignalR and not Azure SignalR.

@vicancy
Copy link
Member

vicancy commented Oct 26, 2023

Hi @davidfowl / @BrennanConroy do you know who we can contact to update the dotnet publish behavior?

@BrennanConroy
Copy link
Collaborator

Do you have the ASP.NET Core Logging Integration site extension installed in your azure app service app? There is an old bug where it overwrites a couple environment variables (like ASPNETCORE_HOSTINGSTARTUPASSEMBLIES), so when you remove the extension that environment variable will start working.
dotnet/aspnetcore#4136

@vicancy vicancy added the pending-customer-confirmation Suggestions provided, waiting for the customer's confirmation label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-customer-confirmation Suggestions provided, waiting for the customer's confirmation
Projects
None yet
Development

No branches or pull requests

5 participants