Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 3.89 KB

signalr-quickstart-azure-functions-javascript.md

File metadata and controls

76 lines (48 loc) · 3.89 KB
title description author ms.service ms.devlang ms.topic ms.date ms.author
Use JavaScript to create a chat room with Azure Functions and SignalR Service
A quickstart for using Azure SignalR Service and Azure Functions to create a chat room.
sffamily
signalr
javascript
quickstart
12/14/2019
zhshang

Quickstart: Use JavaScript to create a chat room with Azure Functions and SignalR Service

Azure SignalR Service lets you easily add real-time functionality to your application and Azure Functions is a serverless platform that lets you run your code without managing any infrastructure. In this quickstart, you use JavaScript to build a serverless, real-time chat application using SignalR Service and Functions.

Prerequisites

Note

This quickstart can be run on macOS, Windows, or Linux.

Log in to Azure

Sign in to the Azure portal at https://portal.azure.com/ with your Azure account.

[!INCLUDE Create instance]

[!INCLUDE Clone application]

Configure and run the Azure Function app

  1. In the browser where the Azure portal is opened, confirm the SignalR Service instance you deployed earlier was successfully created by searching for its name in the search box at the top of the portal. Select the instance to open it.

    Search for the SignalR Service instance

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

  3. Select and copy the primary connection string.

    Create SignalR Service

  4. In your code editor, open the src/chat/javascript folder in the cloned repository.

  5. Rename local.settings.sample.json to local.settings.json.

  6. In local.settings.json, paste the connection string into the value of the AzureSignalRConnectionString setting. Save the file.

  7. JavaScript functions are organized into folders. In each folder are two files: function.json defines the bindings that are used in the function, and index.js is the body of the function. There are two HTTP triggered functions in this function app:

    • negotiate - Uses the SignalRConnectionInfo input binding to generate and return valid connection information.
    • messages - Receives a chat message in the request body and uses the SignalR output binding to broadcast the message to all connected client applications.
  8. In the terminal, ensure that you are in the src/chat/javascript folder. Run the function app.

    func start

    Create SignalR Service

[!INCLUDE Run web application]

[!INCLUDE Cleanup]

Next steps

In this quickstart, you built and ran a real-time serverless application in VS Code. Next, learn more about how to deploy Azure Functions from VS Code.

[!div class="nextstepaction"] Deploy Azure Functions with VS Code