Language

Using SignalR with Azure Web Sites

By Patrick Fletcher|

This document describes how to configure a SignalR application that runs on Microsoft Azure.

Software versions used in the tutorial

  • Visual Studio 2013 or Visual Studio 2012
  • .NET 4.5
  • SignalR version 2
  • Azure SDK 2.3 for Visual Studio 2013 or 2012

Questions and comments

Please leave feedback on how you liked this tutorial and what we could improve in the comments at the bottom of the page. If you have questions that are not directly related to the tutorial, you can post them to the ASP.NET SignalR forum, StackOverflow.com, or the Microsoft Azure forums.

Table of Contents

Introduction

ASP.NET SignalR can be used to bring a new level of interactivity between servers and web or .NET clients. When hosted in Azure, SignalR applications can take advantage of the highly available, scalable, and performant environment that running in the cloud provides.

Deploying a SignalR application to an Azure Web Site

SignalR doesn't add any particular complications to deploying an application to Azure versus deploying to an on-premises server. An application that uses SignalR can be hosted in Azure without any changes in configuration or other settings (though for WebSockets support, see Enabling WebSockets on Azure Web Sites below.) For this tutorial, you'll deploy the application created in the Getting Started Tutorial to Azure.

Prerequisites

Deploying a SignalR application to Azure

  1. Complete the Getting Started Tutorial, or download the finished project from Code Gallery.

  2. In Visual Studio, select Build, Publish SignalR Chat.

  3. In the "Publish Web" dialog, select "Windows Azure Web Sites".

    Select Azure Web Sites
  4. If you aren't signed in to your Microsoft account, click Sign In... in the "Select Existing Web Site" dialog, and sign in.

    Select Existing Web SiteSign in to Azure
  5. In the "Select Existing Web Site" dialog, click New.

    New Web Site
  6. In the "Create site on Windows Azure" dialog, enter a unique site name (I added my initials to the suggested "SignalRChat" site name). Select the region closest to you in the Region dropdown. Click Create.

    Create site on Azure
  7. In the "Publish Web" dialog, click Publish.

    Publish site
  8. When the site has completed publishing, the SignalR Chat application hosted in an Azure Web Site will open in a browser.

    Site opening in a browser

Enabling WebSockets on Azure Web Sites

WebSockets needs to be explicitly enabled in Azure Web Sites to be used in a SignalR application; otherwise, other protocols will be used (See Transports and Fallbacks for details).

Note that WebSockets is only available on Basic and Standard tier Azure Web Sites, and that the number of active Web Socket connections is restricted for Basic tier sites. See Web Sites Pricing Details for more information.

In order to use WebSockets on Azure Web Sites, enable it in the configuration section of the site. To do this, open your web site in the Azure Management Portal, and select Configure.

Configure tab

At the top of the configuration page, ensure that .NET 4.5 is used for your web site.

.NET framework version 4.5 setting

On the configuration page, in the WebSockets setting, select On.

WebSockets setting: On

At the bottom of the Configuration page, select Save to save your changes.

Save settings

Using the Azure Service Bus Backplane

If you use multiple instances for your web site, and the users of those instances need to interact with one another (so that, for instance, chat messages created in one instance can reach the users connected to other instances), the Azure Service Bus backplane must be implemented in your application.

Next Steps

For more information on Azure Web Sites, see Azure Web Sites.

Author Information

Patrick Fletcher

Patrick Fletcher – Patrick Fletcher is a programmer-writer on the ASP.NET team, currently working on SignalR.