Edit

Share via


Quickstart: Connect to the Azure Web PubSub instance from the browser

This quickstart shows you how to get started easily with a Pub/Sub live demo.

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

Sign in to Azure

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

Create an Azure Web PubSub service instance

Your application will connect to a Web PubSub 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 Web PubSub in the search box and press enter. (You could also search the Azure Web PubSub from the Web category.)

    Screenshot of searching the Azure Web PubSub in portal.

  2. Select Web PubSub from the search results, then select Create.

  3. Enter the following settings.

    Setting Suggested value Description
    Resource name Globally unique name The globally unique Name that identifies your new Web PubSub service instance. Valid characters are a-z, A-Z, 0-9, and -.
    Subscription Your subscription The Azure subscription under which this new Web PubSub service instance is created.
    Resource Group myResourceGroup Name for the new resource group in which to create your Web PubSub service instance.
    Location West US Choose a region near you.
    Pricing tier Free You can first try Azure Web PubSub service for free. Learn more details about Azure Web PubSub service pricing tiers
    Unit count - Unit count specifies how many connections your Web PubSub service instance can accept. Each unit supports 1,000 concurrent connections at most. It is only configurable in the Standard tier.

    Screenshot of creating the Azure Web PubSub instance in portal.

  4. Select Create to start deploying the Web PubSub service instance.

Get the client URL with a temp access token

Azure portal provides a simple client URL Generator to generate a temp URL for quick test/validation purpose. Let's use this tool to get a temp Client Access URL and connect to the instance.

  • Go to Azure portal and find out the Azure Web PubSub instance.
  • Go to the Client URL Generator in Key blade.
  • Set proper Roles: Send To Groups and Join/Leave Groups
  • Generate and copy the Client Access URL.

Screenshot of generating client URL.

Try the instance with an online demo

With this live demo, you could join or leave a group and send messages to the group members easily:

Note

Client Access URL is a convenience tool provided in the portal to simplify your getting-started experience, you can also use this Client Access URL to do some quick connect test. To write your own application, we provide SDKs in 4 languages to help you generate the URL.

  • Try different groups to join and different groups to send messages to, and see what messages are received. For example:
    • Make two clients join the same group. You'll see that the message could broadcast to the group members.
    • Make two clients join different groups. You'll see that the client can't receive message if it is not group member.
  • You can also try to uncheck Roles when generating the Client Access URL to see what will happen when join a group or send messages to a group. For example:
    • Uncheck the Send to Groups permission. You'll see that the client can't send messages to the group.
    • Uncheck the Join/Leave Groups permission. You'll see that the client can't join a group.

Next steps

In this quickstart, we use the Client URL Generator to generate a temporarily available client URL to connect to the service, and provide you some basic ideas of the Web PubSub service.

In real-world applications, you can use SDKs in various languages build your own application. We also provide Function extensions for you to build serverless applications easily.

Use these resources to start building your own application: