docs/daprdocs/content/en/reference/components-reference/supported-bindings/signalr.md

4.3 KiB

type title linkTitle description aliases
docs Azure SignalR binding spec Azure SignalR Detailed documentation on the Azure SignalR binding component
/operations/components/setup-bindings/supported-bindings/signalr/

Component format

To setup Azure SignalR binding create a component of type bindings.azure.signalr. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: <NAME>
spec:
  type: bindings.azure.signalr
  version: v1
  metadata:
  - name: connectionString
    value: "Endpoint=https://<your-azure-signalr>.service.signalr.net;AccessKey=<your-access-key>;Version=1.0;"
  - name: hub  # Optional
    value: "<hub name>"

{{% alert title="Warning" color="warning" %}} The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}}

Spec metadata fields

Field Required Binding support Details Example
connectionString Y Output The Azure SignalR connection string "Endpoint=https://<your-azure-signalr>.service.signalr.net;AccessKey=<your-access-key>;Version=1.0;"
hub N Output Defines the hub in which the message will be send. The hub can be dynamically defined as a metadata value when publishing to an output binding (key is "hub") "myhub"
endpoint N Output Endpoint of Azure SignalR; required if not included in the connectionString or if using Microsoft Entra ID "https://<your-azure-signalr>.service.signalr.net"
accessKey N Output Access key "your-access-key"

Microsoft Entra ID authentication

The Azure SignalR binding component supports authentication using all Microsoft Entra ID mechanisms. See the [docs for authenticating to Azure]({{< ref authenticating-azure.md >}}) to learn more about the relevant component metadata fields based on your choice of Microsoft Entra ID authentication mechanism.

You have two options to authenticate this component with Microsoft Entra ID:

  • Pass individual metadata keys:
    • endpoint for the endpoint
    • If needed: azureClientId, azureTenantId and azureClientSecret
  • Pass a connection string with AuthType=aad specified:
    • System-assigned managed identity: Endpoint=https://<servicename>.service.signalr.net;AuthType=aad;Version=1.0;
    • User-assigned managed identity: Endpoint=https://<servicename>.service.signalr.net;AuthType=aad;ClientId=<clientid>;Version=1.0;
    • Microsoft Entra ID application: Endpoint=https://<servicename>.service.signalr.net;AuthType=aad;ClientId=<clientid>;ClientSecret=<clientsecret>;TenantId=<tenantid>;Version=1.0;
      Note that you cannot use a connection string if your application's ClientSecret contains a ; character.

Binding support

This component supports output binding with the following operations:

  • create

Additional information

By default the Azure SignalR output binding will broadcast messages to all connected users. To narrow the audience there are two options, both configurable in the Metadata property of the message:

  • group: Sends the message to a specific Azure SignalR group
  • user: Sends the message to a specific Azure SignalR user

Applications publishing to an Azure SignalR output binding should send a message with the following contract:

{
    "data": {
        "Target": "<enter message name>",
        "Arguments": [
            {
                "sender": "dapr",
                "text": "Message from dapr output binding"
            }
        ]
    },
    "metadata": {
        "group": "chat123"
    },
    "operation": "create"
}

For more information on integration Azure SignalR into a solution check the documentation

  • [Basic schema for a Dapr component]({{< ref component-schema >}})
  • [Bindings building block]({{< ref bindings >}})
  • [How-To: Trigger application with input binding]({{< ref howto-triggers.md >}})
  • [How-To: Use bindings to interface with external resources]({{< ref howto-bindings.md >}})
  • [Bindings API reference]({{< ref bindings_api.md >}})