Enterprise Framework

Software Solutions in the Enterprise

How To : SignalR with Azure Service Bus - Full Details

SignalR with Azure Service Bus

The steps defined within "Scaleout with Windows Azure Service Bus" was good, but not complete from my viewpoint.  Here's what you do assuming you did the prerequisites:

Step 1 : Setup Azure Cloud Services

  1. Login to Azure
  2. Click CLOUD SERVICES and Choose +NEW
  3. Choose COMPUTE > CLOUD SERVICE > Quick Create > Url > MySignalr.Cloud.Service
  4. Choose the correct hosting region
Step 2 : Setup Azure Service Bus

  1. Login to Azure
  2. Click SERVICE BUS and Choose +NEW
    1. NAMESPACE NAME: MySignalR
    2. REGION:  West US
  3. Click the Checkmark
  4. Click the newly created namespace
  5. Click Connection Strings from Below
  6. Copy the connection string, you'll use it in your Web Project
Step 3 : Setup Visual Studio 2013 Solutions

  1. Open Visual Studio 2013 as Administrator
  2. File > New Project
  3. Click Installed > Templates > Visual C# > Cloud 
  4. Click Windows Azure Cloud Service
    1. Enter the following values:
      1. Name:  MySignalR.Cloud.Service
      2. Solution Name: MySignalR
      3. Click OK
  5. In the ".NET Framework 4.5 roles" column, choose "ASP.NET Web Role" and click [>]
    1. In the right column of Windows Azure Cloud Service Solution, Click on WebRole1 and then click the pencil to edit.
    2. Change the name to MySignalR.Web and click the empty space beneath.
    3. Click OK
  6. New ASP.NET Project - MySignalR.Web
    1. Choose MVC
    2. Choose Add unit tests
    3. Click OK
  7. Then the instructions on ASP.NET tell you to install SignalR
    1. Install-Package -ProjectName SignalRChat Microsoft.AspNet.SignalR
      Install-Package -ProjectName SignalRChat Microsoft.AspNet.SignalR.ServiceBus
  8. Set the backplane for Azure
    1. Update Web.Config so the connection string can be stored there.

          <add name="AzureServiceBus" connectionString="Endpoint=sb://xxxx.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=XXXXXXXX" />
    2. Startup.cs
      public void Configuration(IAppBuilder app)
          // Any connection or hub wire up and configuration should go here
          string connectionString = ConfigurationManager.ConnectionStrings["AzureServiceBus"].ConnectionString;
      GlobalHost.DependencyResolver.UseServiceBus(connectionString, "Chat"); app.MapSignalR(); }
  9. Update the MySignalR.Cloud.Service files
    1. Open ServiceConfiguration.Cloud.cscfg and add a line for Microsoft.ServiceBus.ConnectionString with the value defined in the service bus dashboard.                 

      <?xml version="1.0" encoding="utf-8"?>
      <ServiceConfiguration serviceName="MySignalR.Cloud.Service" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-01.2.3">
        <Role name="MySignalR.Web">
          <Instances count="1" />
            <Setting name="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://xxxx.servicebus.windows.net/;SharedSecretIssuer=owner;SharedSecretValue=XXXXXXXX" />
            <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName={AccountName};AccountKey={AccountKey}" />     </ConfigurationSettings>   </Role> </ServiceConfiguration>
    Right click the the MySignalR.Service.Cloud project and click Publish

Comments are closed