question

ravivenkat-7288 avatar image
0 Votes"
ravivenkat-7288 asked Grmacjon-MSFT edited

can we Integrate Signal R service with a Node Js Application ?

HI all
We are hosting a Single page application using NodeJS ( angular ) with cosmos DB on a Webapp. We want to add a Realtime functionality to this application. Can we use a Azure Signal R service to achieve this kind of functionality ? I found in most of the documents it's supporting only .NET applications. Can it support angular based web applications ?

azure-cosmos-dbazure-signalr-service
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Grmacjon-MSFT avatar image
0 Votes"
Grmacjon-MSFT answered Grmacjon-MSFT edited

Hi @ravivenkat-7288

Thanks for the question.

Yes, you should be able to use Azure Signal R with Angular application. Based on this StackOverflow thread:


"You can connect Azure SignalR Hub from Angular using connection string which can be get from appsettings.json by following the steps below:

Azure SignalR SDK allows the ease of use API just to change a couple of APIs and ready to use Azure SignalR service. To use this service, we have to AddAzureSignalR in configure service method and pass the Azure connection string which is copied from the Azure portal. Passing the same using configuration file (appsettings.json).

 // This method gets called by the runtime. Use this method to add services to the container.
    
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
    
     // In production, the Angular files will be served from this directory
    
     services.AddSpaStaticFiles(configuration =>
     {
         configuration.RootPath = "ClientApp/dist";
     });
     services.AddSignalR().AddAzureSignalR(Configuration["Azure:SignalR:ConnectionString"]);
    
 }

After adding Azure SignalR service, we need to use the Azure SignalR route pipeline to map the hub which is done in the configure method. Map the hub with URL to work correctly.

 // Azure SignalR service
    
 app.UseAzureSignalR(routes =>
 {
     routes.MapHub<ChatHub>("/chat");
 });

"

Another way to connect your Angular app with SignlaR is to use Azure Functions. To learn more about this option please read this blog post

Hope that helps. Please let us know if you have further questions

Thanks,
Grace



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.