Web Pub Sub Hubs - Create Or Update

Create or update a hub setting.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/webPubSub/{resourceName}/hubs/{hubName}?api-version=2024-03-01

URI Parameters

Name In Required Type Description
hubName
path True

string

The hub name.

resourceGroupName
path True

string

The name of the resource group. The name is case insensitive.

resourceName
path True

string

The name of the resource.

Regex pattern: ^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]$

subscriptionId
path True

string

uuid

The ID of the target subscription. The value must be an UUID.

api-version
query True

string

The API version to use for this operation.

Request Body

Name Required Type Description
properties True

WebPubSubHubProperties

Properties of a hub.

Responses

Name Type Description
200 OK

WebPubSubHub

OK.The request makes no change. The response describes the existing hub setting.

201 Created

WebPubSubHub

Created. The response describes the hub setting and contains a Location header to query the operation result.

Other Status Codes

ErrorResponse

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

WebPubSubHubs_CreateOrUpdate

Sample Request

PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.SignalRService/webPubSub/myWebPubSubService/hubs/exampleHub?api-version=2024-03-01

{
  "properties": {
    "eventHandlers": [
      {
        "urlTemplate": "http://host.com",
        "userEventPattern": "*",
        "systemEvents": [
          "connect",
          "connected"
        ],
        "auth": {
          "type": "ManagedIdentity",
          "managedIdentity": {
            "resource": "abc"
          }
        }
      }
    ],
    "eventListeners": [
      {
        "filter": {
          "type": "EventName",
          "systemEvents": [
            "connected",
            "disconnected"
          ],
          "userEventPattern": "*"
        },
        "endpoint": {
          "type": "EventHub",
          "fullyQualifiedNamespace": "example.servicebus.windows.net",
          "eventHubName": "eventHubName1"
        }
      }
    ],
    "anonymousConnectPolicy": "allow",
    "webSocketKeepAliveIntervalInSeconds": 50
  }
}

Sample Response

{
  "properties": {
    "eventHandlers": [
      {
        "urlTemplate": "http://host.com",
        "userEventPattern": "*",
        "systemEvents": [
          "connect",
          "connected"
        ],
        "auth": {
          "type": "ManagedIdentity",
          "managedIdentity": {
            "resource": "abc"
          }
        }
      }
    ],
    "eventListeners": [
      {
        "filter": {
          "type": "EventName",
          "systemEvents": [
            "connected",
            "disconnected"
          ],
          "userEventPattern": "*"
        },
        "endpoint": {
          "type": "EventHub",
          "fullyQualifiedNamespace": "example.servicebus.windows.net",
          "eventHubName": "eventHubName1"
        }
      }
    ],
    "anonymousConnectPolicy": "allow",
    "webSocketKeepAliveIntervalInSeconds": 50
  },
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/WebPubSub/myWebPubSubService/hubs/exampleHub",
  "name": "exampleHub",
  "type": "Microsoft.SignalRService/WebPubSub/hubs"
}
Location: https://management.azure.com/subscriptions/subid/providers/Microsoft.SignalRService/...pathToOperationResult...
Azure-AsyncOperation: https://management.azure.com/subscriptions/subid/providers/Microsoft.SignalRService/...pathToOperationStatus...
{
  "properties": {
    "eventHandlers": [
      {
        "urlTemplate": "http://host.com",
        "userEventPattern": "*",
        "systemEvents": [
          "connect",
          "connected"
        ],
        "auth": {
          "type": "ManagedIdentity",
          "managedIdentity": {
            "resource": "abc"
          }
        }
      }
    ],
    "eventListeners": [
      {
        "filter": {
          "type": "EventName",
          "systemEvents": [
            "connected",
            "disconnected"
          ],
          "userEventPattern": "*"
        },
        "endpoint": {
          "type": "EventHub",
          "fullyQualifiedNamespace": "example.servicebus.windows.net",
          "eventHubName": "eventHubName1"
        }
      }
    ],
    "anonymousConnectPolicy": "allow",
    "webSocketKeepAliveIntervalInSeconds": 50
  },
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/WebPubSub/myWebPubSubService/hubs/exampleHub",
  "name": "exampleHub",
  "type": "Microsoft.SignalRService/WebPubSub/hubs"
}

Definitions

Name Description
createdByType

The type of identity that created the resource.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

EventHandler

Properties of event handler.

EventHubEndpoint

An Event Hub endpoint. The managed identity of Web PubSub service must be enabled, and the identity should have the "Azure Event Hubs Data sender" role to access Event Hub.

EventListener

A setting defines which kinds of events should be sent to which endpoint.

EventNameFilter

Filter events by their name.

ManagedIdentitySettings

Managed identity settings for upstream.

systemData

Metadata pertaining to creation and last modification of the resource.

UpstreamAuthSettings

Upstream auth settings. If not set, no auth is used for upstream messages.

UpstreamAuthType

Upstream auth type enum.

WebPubSubHub

A hub setting

WebPubSubHubProperties

Properties of a hub.

createdByType

The type of identity that created the resource.

Name Type Description
Application

string

Key

string

ManagedIdentity

string

User

string

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

EventHandler

Properties of event handler.

Name Type Description
auth

UpstreamAuthSettings

Upstream auth settings. If not set, no auth is used for upstream messages.

systemEvents

string[]

Gets or sets the list of system events.

urlTemplate

string

Gets or sets the EventHandler URL template. You can use a predefined parameter {hub} and {event} inside the template, the value of the EventHandler URL is dynamically calculated when the client request comes in. For example, UrlTemplate can be http://example.com/api/{hub}/{event}. The host part can't contains parameters.

userEventPattern

string

Gets or sets the matching pattern for event names. There are 3 kinds of patterns supported: 1. "*", it matches any event name 2. Combine multiple events with ",", for example "event1,event2", it matches event "event1" and "event2" 3. A single event name, for example, "event1", it matches "event1"

EventHubEndpoint

An Event Hub endpoint. The managed identity of Web PubSub service must be enabled, and the identity should have the "Azure Event Hubs Data sender" role to access Event Hub.

Name Type Description
eventHubName

string

The name of the Event Hub.

fullyQualifiedNamespace

string

The fully qualified namespace name of the Event Hub resource. For example, "example.servicebus.windows.net".

type string:

EventHub

EventListener

A setting defines which kinds of events should be sent to which endpoint.

Name Type Description
endpoint EventListenerEndpoint:

EventHubEndpoint

An endpoint specifying where Web PubSub should send events to.

filter EventListenerFilter:

EventNameFilter

A base class for event filter which determines whether an event should be sent to an event listener.

EventNameFilter

Filter events by their name.

Name Type Description
systemEvents

string[]

Gets or sets a list of system events. Supported events: "connected" and "disconnected". Blocking event "connect" is not supported because it requires a response.

type string:

EventName

userEventPattern

string

Gets or sets a matching pattern for event names. There are 3 kinds of patterns supported: 1. "*", it matches any event name 2. Combine multiple events with ",", for example "event1,event2", it matches events "event1" and "event2" 3. A single event name, for example, "event1", it matches "event1"

ManagedIdentitySettings

Managed identity settings for upstream.

Name Type Description
resource

string

The Resource indicating the App ID URI of the target resource. It also appears in the aud (audience) claim of the issued token.

systemData

Metadata pertaining to creation and last modification of the resource.

Name Type Description
createdAt

string

The timestamp of resource creation (UTC).

createdBy

string

The identity that created the resource.

createdByType

createdByType

The type of identity that created the resource.

lastModifiedAt

string

The timestamp of resource last modification (UTC)

lastModifiedBy

string

The identity that last modified the resource.

lastModifiedByType

createdByType

The type of identity that last modified the resource.

UpstreamAuthSettings

Upstream auth settings. If not set, no auth is used for upstream messages.

Name Type Description
managedIdentity

ManagedIdentitySettings

Managed identity settings for upstream.

type

UpstreamAuthType

Upstream auth type enum.

UpstreamAuthType

Upstream auth type enum.

Name Type Description
ManagedIdentity

string

None

string

WebPubSubHub

A hub setting

Name Type Description
id

string

Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"

name

string

The name of the resource

properties

WebPubSubHubProperties

Properties of a hub.

systemData

systemData

Azure Resource Manager metadata containing createdBy and modifiedBy information.

type

string

The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"

WebPubSubHubProperties

Properties of a hub.

Name Type Default Value Description
anonymousConnectPolicy

string

deny

The settings for configuring if anonymous connections are allowed for this hub: "allow" or "deny". Default to "deny".

eventHandlers

EventHandler[]

Event handler of a hub.

eventListeners

EventListener[]

Event listener settings for forwarding your client events to listeners. Event listener is transparent to Web PubSub clients, and it doesn't return any result to clients nor interrupt the lifetime of clients. One event can be sent to multiple listeners, as long as it matches the filters in those listeners. The order of the array elements doesn't matter. Maximum count of event listeners among all hubs is 10.

webSocketKeepAliveIntervalInSeconds

integer

20

The settings for configuring the WebSocket ping-pong interval in seconds for all clients in the hub. Valid range: 1 to 120. Default to 20 seconds.