Quickstart: Create a chat room with ASP.NET and SignalR Service

Azure SignalR Service is based on SignalR for ASP.NET Core 2.1, which is not 100% compatible with ASP.NET SignalR. Azure SignalR Service re-implemented ASP.NET SignalR data protocol based on the latest ASP.NET Core technologies. When using Azure SignalR Service for ASP.NET SignalR, some ASP.NET SignalR features are no longer supported, for example, Azure SignalR does not replay messages when the client reconnects. Also, the Forever Frame transport and JSONP are not supported. Some code changes and proper version of dependent libraries are needed to make ASP.NET SignalR application work with SignalR Service.

Refer to the version differences doc for a complete list of feature comparison between ASP.NET SignalR and ASP.NET Core SignalR.

In this quickstart, you will learn how to get started with the ASP.NET and Azure SignalR Service for a similar Chat Room application.

If you don't have an Azure subscription, create a free account before you begin.


Having issues? Try the troubleshooting guide or let us know.

Sign in to Azure

Sign in to the Azure portal with your Azure account.

Having issues? Try the troubleshooting guide or let us know.

Create an Azure SignalR Service instance

Your application will connect to a SignalR Service instance in Azure.

  1. Select the New button found on the upper left-hand corner of the Azure portal. In the New screen, type SignalR Service in the search box and press enter.

    Screenshot shows search for SignalR Service in the Azure portal.

  2. Select SignalR Service from the search results, then select Create.

  3. Enter the following settings.

    Setting Suggested value Description
    Resource name Globally unique name Name that identifies your new SignalR Service instance. Valid characters are a-z, 0-9, and -.
    Subscription Your subscription The subscription under which this new SignalR Service instance is created.
    Resource Group myResourceGroup Name for the new resource group in which to create your SignalR Service instance.
    Location West US Choose a region near you.
    Pricing tier Free Try Azure SignalR Service for free.
    Unit count Not applicable Unit count specifies how many connections your SignalR Service instance can accept. It is only configurable in the Standard tier.
    Service mode Serverless For use with Azure Functions or REST API.

    Screenshot shows SignalR Basics tab with values.

  4. Select Create to start deploying the SignalR Service instance.

  5. After the instance is deployed, open it in the portal and locate its Settings page. Change the Service Mode setting to Serverless only if you are using Azure SignalR Service through Azure Functions binding or REST API. Leave it in Classic or Default otherwise.

Serverless mode is not supported for ASP.NET SignalR applications. Always use Default or Classic for the Azure SignalR Service instance.

You can also create Azure resources used in this quickstart with Create a SignalR Service script.

Having issues? Try the troubleshooting guide or let us know.

Clone the sample application

While the service is deploying, let's switch to working with code. Clone the sample app from GitHub, set the SignalR Service connection string, and run the application locally.

  1. Open a git terminal window. Change to a folder where you want to clone the sample project.

  2. Run the following command to clone the sample repository. This command creates a copy of the sample app on your computer.

    git clone https://github.com/aspnet/AzureSignalR-samples.git

Having issues? Try the troubleshooting guide or let us know.

Configure and run Chat Room web app

  1. Start Visual Studio and open the solution in the aspnet-samples/ChatRoom/ folder of the cloned repository.

  2. In the browser where the Azure portal is opened, find and select the instance you created.

  3. Select Keys to view the connection strings for the SignalR Service instance.

  4. Select and copy the primary connection string.

  5. Now set the connection string in the web.config file.

        <add name="Azure:SignalR:ConnectionString" connectionString="<Replace By Your Connection String>"/>
  6. In Startup.cs, instead of calling MapSignalR(), you need to call MapAzureSignalR({YourApplicationName}) and pass in connection string to make the application connect to the service instead of hosting SignalR by itself. Replace {YourApplicationName} to the name of your application. This name is a unique name to distinguish this application from your other applications. You can use this.GetType().FullName as the value.

    public void Configuration(IAppBuilder app)
        // Any connection or hub wire up and configuration should go here

    You also need to reference the service SDK before using these APIs. Open the Tools | NuGet Package Manager | Package Manager Console and run command:

    Install-Package Microsoft.Azure.SignalR.AspNet

    Other than these changes, everything else remains the same, you can still use the hub interface you're already familiar with to write business logic.


    In the implementation an endpoint /signalr/negotiate is exposed for negotiation by Azure SignalR Service SDK. It will return a special negotiation response when clients try to connect and redirect clients to service endpoint defined in the connection string.

  7. Press F5 to run the project in debug mode. You can see the application runs locally. Instead of hosting a SignalR runtime by application itself, it now connects to the Azure SignalR Service.

Having issues? Try the troubleshooting guide or let us know.

Clean up resources

If you're not going to continue to use this app, delete all resources created by this quickstart with the following steps so you don't incur any charges:

  1. In the Azure portal, select Resource groups on the far left, and then select the resource group you created. Alternatively, you may use the search box to find the resource group by its name.

  2. In the window that opens, select the resource group, and then click Delete resource group.

  3. In the new window, type the name of the resource group to delete, and then click Delete.


Deleting a resource group is irreversible and that the resource group and all the resources in it are permanently deleted. Make sure that you do not accidentally delete the wrong resource group or resources. If you created the resources for hosting this sample inside an existing resource group that contains resources you want to keep, you can delete each resource individually from their respective blades instead of deleting the resource group.

Sign in to the Azure portal and click Resource groups.

In the Filter by name... textbox, type the name of your resource group. The instructions for this quickstart used a resource group named SignalRTestResources. On your resource group in the result list, click ... then Delete resource group.


After a few moments, the resource group and all of its contained resources are deleted.

Having issues? Try the troubleshooting guide or let us know.

Next steps

In this quickstart, you created a new Azure SignalR Service resource and used it with an ASP.NET web app. Next, learn how to develop real-time applications using Azure SignalR Service with ASP.NET Core.