Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When developing serverless applications, we provide an Azure SignalR Local Emulator to make the local development and integration easier. The emulator works only for serverless scenarios, for Default mode that the Azure SignalR Service acts as a proxy, you can directly use self-host SignalR to do local development. Also note that emulator only works for Transient transport type (the default one) and doesn't support Persistent transport type.
Features available
- Auth
 - Latest Rest API support
 - Upstream
 
Important
Raw connection strings appear in this article for demonstration purposes only.
A connection string includes the authorization information required for your application to access Azure SignalR Service. The access key inside the connection string is similar to a root password for your service. In production environments, always protect your access keys. Use Azure Key Vault to manage and rotate your keys securely and secure your connection string using Microsoft Entra ID and authorize access with Microsoft Entra ID.
Avoid distributing access keys to other users, hard-coding them, or saving them anywhere in plain text that is accessible to others. Rotate your keys if you believe they may have been compromised.
Walkthrough
We use this serverless sample to show how to use the emulator.
Raw connection strings appear in this article for demonstration purposes only. In production environments, always protect your access keys. Use Azure Key Vault to manage and rotate your keys securely and secure your connection string using Microsoft Entra ID and authorize access with Microsoft Entra ID.
Clone the sample repo to local
git clone https://github.com/Azure/azure-functions-signalrservice-extension.git cd azure-functions-signalrservice-extension/samples/bidirectional-chatInstall the emulator
dotnet tool install -g Microsoft.Azure.SignalR.EmulatorOr update the emulator to the latest preview version if it's already installed:
dotnet tool update -g Microsoft.Azure.SignalR.EmulatorRun the emulator
asrs-emulatorto list all the available commands
Init the default upstream settings using:
asrs-emulator upstream initIt creates a default
settings.jsoninto the current folder, with a default upstreamUrlTemplateashttp://localhost:7071/runtime/webhooks/signalr, which is the URL for SignalR's local function trigger:{ "UpstreamSettings": { "Templates": [ { "UrlTemplate": "http://localhost:7071/runtime/webhooks/signalr", "EventPattern": "*", "HubPattern": "*", "CategoryPattern": "*" } ] } }You could edit the file to make the pattern more restricted, for example, change
HubPatternfrom*tochat. When the file is modified, its change is hot-loaded into the emulator.Start the emulator
asrs-emulator startAfter the emulator is successfully started, it generates the ConnectionString to be used later.
The emulator also provides advanced options when start, for example, you can use
asrs-emulator start -p 8999to customize the port the emulator used. Typeasrs-emulator start --helpto check the options available.Go into subfolder
csharpand renamelocal.settings.sample.jsontolocal.settings.json, use the ConnectionString generated by the emulator to fill into the value of the AzureSignalRConnectionString in your local.settings.json. Fill intoAzureWebJobsStorageyour storage connection string, for example,UseDevelopmentStorage=truewhen using storage emulator. Save the file and run the function in thecsharpsubfolder withfunc start.
In the browser, navigate to
http://localhost:7071/api/indexto play with the demo.
Next steps
In this article, you learn how to use SignalR Service in your applications. Check the following articles to learn more about SignalR Service.