We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
Manages the hub settings for a Web Pubsub.
Example Usage
using Pulumi;
using Azure = Pulumi.Azure;
class MyStack : Stack
{
public MyStack()
{
var exampleResourceGroup = new Azure.Core.ResourceGroup("exampleResourceGroup", new Azure.Core.ResourceGroupArgs
{
Location = "east us",
});
var testUserAssignedIdentity = new Azure.Authorization.UserAssignedIdentity("testUserAssignedIdentity", new Azure.Authorization.UserAssignedIdentityArgs
{
ResourceGroupName = exampleResourceGroup.Name,
Location = exampleResourceGroup.Location,
});
var exampleService = new Azure.WebPubSub.Service("exampleService", new Azure.WebPubSub.ServiceArgs
{
Location = exampleResourceGroup.Location,
ResourceGroupName = exampleResourceGroup.Name,
Sku = "Standard_S1",
Capacity = 1,
});
var testHub = new Azure.WebPubSub.Hub("testHub", new Azure.WebPubSub.HubArgs
{
WebPubsubId = azurerm_web_pubsub.Exmaple.Id,
EventHandlers =
{
new Azure.WebPubSub.Inputs.HubEventHandlerArgs
{
UrlTemplate = "https://test.com/api/{hub}/{event}",
UserEventPattern = "*",
SystemEvents =
{
"connect",
"connected",
},
},
new Azure.WebPubSub.Inputs.HubEventHandlerArgs
{
UrlTemplate = "https://test.com/api/{hub}/{event}",
UserEventPattern = "event1, event2",
SystemEvents =
{
"connected",
},
Auth = new Azure.WebPubSub.Inputs.HubEventHandlerAuthArgs
{
ManagedIdentityId = testUserAssignedIdentity.Id,
},
},
},
AnonymousConnectionsEnabled = true,
}, new CustomResourceOptions
{
DependsOn =
{
azurerm_web_pubsub.Test,
},
});
}
}
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/authorization"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v4/go/azure/webpubsub"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleResourceGroup, err := core.NewResourceGroup(ctx, "exampleResourceGroup", &core.ResourceGroupArgs{
Location: pulumi.String("east us"),
})
if err != nil {
return err
}
testUserAssignedIdentity, err := authorization.NewUserAssignedIdentity(ctx, "testUserAssignedIdentity", &authorization.UserAssignedIdentityArgs{
ResourceGroupName: exampleResourceGroup.Name,
Location: exampleResourceGroup.Location,
})
if err != nil {
return err
}
_, err = webpubsub.NewService(ctx, "exampleService", &webpubsub.ServiceArgs{
Location: exampleResourceGroup.Location,
ResourceGroupName: exampleResourceGroup.Name,
Sku: pulumi.String("Standard_S1"),
Capacity: pulumi.Int(1),
})
if err != nil {
return err
}
_, err = webpubsub.NewHub(ctx, "testHub", &webpubsub.HubArgs{
WebPubsubId: pulumi.Any(azurerm_web_pubsub.Exmaple.Id),
EventHandlers: webpubsub.HubEventHandlerArray{
&webpubsub.HubEventHandlerArgs{
UrlTemplate: pulumi.String("https://test.com/api/{hub}/{event}"),
UserEventPattern: pulumi.String("*"),
SystemEvents: pulumi.StringArray{
pulumi.String("connect"),
pulumi.String("connected"),
},
},
&webpubsub.HubEventHandlerArgs{
UrlTemplate: pulumi.String("https://test.com/api/{hub}/{event}"),
UserEventPattern: pulumi.String("event1, event2"),
SystemEvents: pulumi.StringArray{
pulumi.String("connected"),
},
Auth: &webpubsub.HubEventHandlerAuthArgs{
ManagedIdentityId: testUserAssignedIdentity.ID(),
},
},
},
AnonymousConnectionsEnabled: pulumi.Bool(true),
}, pulumi.DependsOn([]pulumi.Resource{
azurerm_web_pubsub.Test,
}))
if err != nil {
return err
}
return nil
})
}
Example coming soon!
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const exampleResourceGroup = new azure.core.ResourceGroup("exampleResourceGroup", {location: "east us"});
const testUserAssignedIdentity = new azure.authorization.UserAssignedIdentity("testUserAssignedIdentity", {
resourceGroupName: exampleResourceGroup.name,
location: exampleResourceGroup.location,
});
const exampleService = new azure.webpubsub.Service("exampleService", {
location: exampleResourceGroup.location,
resourceGroupName: exampleResourceGroup.name,
sku: "Standard_S1",
capacity: 1,
});
const testHub = new azure.webpubsub.Hub("testHub", {
webPubsubId: azurerm_web_pubsub.exmaple.id,
eventHandlers: [
{
urlTemplate: "https://test.com/api/{hub}/{event}",
userEventPattern: "*",
systemEvents: [
"connect",
"connected",
],
},
{
urlTemplate: "https://test.com/api/{hub}/{event}",
userEventPattern: "event1, event2",
systemEvents: ["connected"],
auth: {
managedIdentityId: testUserAssignedIdentity.id,
},
},
],
anonymousConnectionsEnabled: true,
}, {
dependsOn: [azurerm_web_pubsub.test],
});
import pulumi
import pulumi_azure as azure
example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="east us")
test_user_assigned_identity = azure.authorization.UserAssignedIdentity("testUserAssignedIdentity",
resource_group_name=example_resource_group.name,
location=example_resource_group.location)
example_service = azure.webpubsub.Service("exampleService",
location=example_resource_group.location,
resource_group_name=example_resource_group.name,
sku="Standard_S1",
capacity=1)
test_hub = azure.webpubsub.Hub("testHub",
web_pubsub_id=azurerm_web_pubsub["exmaple"]["id"],
event_handlers=[
azure.webpubsub.HubEventHandlerArgs(
url_template="https://test.com/api/{hub}/{event}",
user_event_pattern="*",
system_events=[
"connect",
"connected",
],
),
azure.webpubsub.HubEventHandlerArgs(
url_template="https://test.com/api/{hub}/{event}",
user_event_pattern="event1, event2",
system_events=["connected"],
auth=azure.webpubsub.HubEventHandlerAuthArgs(
managed_identity_id=test_user_assigned_identity.id,
),
),
],
anonymous_connections_enabled=True,
opts=pulumi.ResourceOptions(depends_on=[azurerm_web_pubsub["test"]]))
Example coming soon!
Create Hub Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Hub(name: string, args: HubArgs, opts?: CustomResourceOptions);@overload
def Hub(resource_name: str,
args: HubArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Hub(resource_name: str,
opts: Optional[ResourceOptions] = None,
event_handlers: Optional[Sequence[HubEventHandlerArgs]] = None,
web_pubsub_id: Optional[str] = None,
anonymous_connections_enabled: Optional[bool] = None,
name: Optional[str] = None)func NewHub(ctx *Context, name string, args HubArgs, opts ...ResourceOption) (*Hub, error)public Hub(string name, HubArgs args, CustomResourceOptions? opts = null)type: azure:webpubsub:Hub
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args HubArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args HubArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args HubArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args HubArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args HubArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var azureHubResource = new Azure.WebPubSub.Hub("azureHubResource", new()
{
EventHandlers = new[]
{
new Azure.WebPubSub.Inputs.HubEventHandlerArgs
{
UrlTemplate = "string",
Auth = new Azure.WebPubSub.Inputs.HubEventHandlerAuthArgs
{
ManagedIdentityId = "string",
},
SystemEvents = new[]
{
"string",
},
UserEventPattern = "string",
},
},
WebPubsubId = "string",
AnonymousConnectionsEnabled = false,
Name = "string",
});
example, err := webpubsub.NewHub(ctx, "azureHubResource", &webpubsub.HubArgs{
EventHandlers: webpubsub.HubEventHandlerArray{
&webpubsub.HubEventHandlerArgs{
UrlTemplate: pulumi.String("string"),
Auth: &webpubsub.HubEventHandlerAuthArgs{
ManagedIdentityId: pulumi.String("string"),
},
SystemEvents: pulumi.StringArray{
pulumi.String("string"),
},
UserEventPattern: pulumi.String("string"),
},
},
WebPubsubId: pulumi.String("string"),
AnonymousConnectionsEnabled: pulumi.Bool(false),
Name: pulumi.String("string"),
})
var azureHubResource = new com.pulumi.azure.webpubsub.Hub("azureHubResource", com.pulumi.azure.webpubsub.HubArgs.builder()
.eventHandlers(HubEventHandlerArgs.builder()
.urlTemplate("string")
.auth(HubEventHandlerAuthArgs.builder()
.managedIdentityId("string")
.build())
.systemEvents("string")
.userEventPattern("string")
.build())
.webPubsubId("string")
.anonymousConnectionsEnabled(false)
.name("string")
.build());
azure_hub_resource = azure.webpubsub.Hub("azureHubResource",
event_handlers=[{
"url_template": "string",
"auth": {
"managed_identity_id": "string",
},
"system_events": ["string"],
"user_event_pattern": "string",
}],
web_pubsub_id="string",
anonymous_connections_enabled=False,
name="string")
const azureHubResource = new azure.webpubsub.Hub("azureHubResource", {
eventHandlers: [{
urlTemplate: "string",
auth: {
managedIdentityId: "string",
},
systemEvents: ["string"],
userEventPattern: "string",
}],
webPubsubId: "string",
anonymousConnectionsEnabled: false,
name: "string",
});
type: azure:webpubsub:Hub
properties:
anonymousConnectionsEnabled: false
eventHandlers:
- auth:
managedIdentityId: string
systemEvents:
- string
urlTemplate: string
userEventPattern: string
name: string
webPubsubId: string
Hub Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Hub resource accepts the following input properties:
- Event
Handlers List<HubEvent Handler> - An
event_handlerblock as defined below. - Web
Pubsub stringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- Anonymous
Connections boolEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - Name string
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- Event
Handlers []HubEvent Handler Args - An
event_handlerblock as defined below. - Web
Pubsub stringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- Anonymous
Connections boolEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - Name string
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- event
Handlers List<HubEvent Handler> - An
event_handlerblock as defined below. - web
Pubsub StringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous
Connections BooleanEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - name String
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- event
Handlers HubEvent Handler[] - An
event_handlerblock as defined below. - web
Pubsub stringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous
Connections booleanEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - name string
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- event_
handlers Sequence[HubEvent Handler Args] - An
event_handlerblock as defined below. - web_
pubsub_ strid - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous_
connections_ boolenabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - name str
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- event
Handlers List<Property Map> - An
event_handlerblock as defined below. - web
Pubsub StringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous
Connections BooleanEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - name String
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
Outputs
All input properties are implicitly available as output properties. Additionally, the Hub resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Hub Resource
Get an existing Hub resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: HubState, opts?: CustomResourceOptions): Hub@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
anonymous_connections_enabled: Optional[bool] = None,
event_handlers: Optional[Sequence[HubEventHandlerArgs]] = None,
name: Optional[str] = None,
web_pubsub_id: Optional[str] = None) -> Hubfunc GetHub(ctx *Context, name string, id IDInput, state *HubState, opts ...ResourceOption) (*Hub, error)public static Hub Get(string name, Input<string> id, HubState? state, CustomResourceOptions? opts = null)public static Hub get(String name, Output<String> id, HubState state, CustomResourceOptions options)resources: _: type: azure:webpubsub:Hub get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Anonymous
Connections boolEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - Event
Handlers List<HubEvent Handler> - An
event_handlerblock as defined below. - Name string
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- Web
Pubsub stringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- Anonymous
Connections boolEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - Event
Handlers []HubEvent Handler Args - An
event_handlerblock as defined below. - Name string
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- Web
Pubsub stringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous
Connections BooleanEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - event
Handlers List<HubEvent Handler> - An
event_handlerblock as defined below. - name String
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- web
Pubsub StringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous
Connections booleanEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - event
Handlers HubEvent Handler[] - An
event_handlerblock as defined below. - name string
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- web
Pubsub stringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous_
connections_ boolenabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - event_
handlers Sequence[HubEvent Handler Args] - An
event_handlerblock as defined below. - name str
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- web_
pubsub_ strid - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
- anonymous
Connections BooleanEnabled - Is anonymous connections are allowed for this hub? Defaults to
false. Possible values aretrue,false. - event
Handlers List<Property Map> - An
event_handlerblock as defined below. - name String
- The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
- web
Pubsub StringId - Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
Supporting Types
HubEventHandler, HubEventHandlerArgs
- Url
Template string - The Event Handler URL Template. Two predefined parameters
{hub}and{event}are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example:http://example.com/api/{hub}/{event}. - Auth
Hub
Event Handler Auth - An
authblock as defined below. - System
Events List<string> - Specify the list of system events. Supported values are
connect,connectedanddisconnected. - User
Event stringPattern - Specify the matching event names. There are 3 kind of patterns supported:
*matches any event name,Combine multiple events with,for exampleevent1,event2, it matches eventevent1andevent2- The single event name, for example
event1, it matchesevent1.
- Url
Template string - The Event Handler URL Template. Two predefined parameters
{hub}and{event}are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example:http://example.com/api/{hub}/{event}. - Auth
Hub
Event Handler Auth - An
authblock as defined below. - System
Events []string - Specify the list of system events. Supported values are
connect,connectedanddisconnected. - User
Event stringPattern - Specify the matching event names. There are 3 kind of patterns supported:
*matches any event name,Combine multiple events with,for exampleevent1,event2, it matches eventevent1andevent2- The single event name, for example
event1, it matchesevent1.
- url
Template String - The Event Handler URL Template. Two predefined parameters
{hub}and{event}are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example:http://example.com/api/{hub}/{event}. - auth
Hub
Event Handler Auth - An
authblock as defined below. - system
Events List<String> - Specify the list of system events. Supported values are
connect,connectedanddisconnected. - user
Event StringPattern - Specify the matching event names. There are 3 kind of patterns supported:
*matches any event name,Combine multiple events with,for exampleevent1,event2, it matches eventevent1andevent2- The single event name, for example
event1, it matchesevent1.
- url
Template string - The Event Handler URL Template. Two predefined parameters
{hub}and{event}are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example:http://example.com/api/{hub}/{event}. - auth
Hub
Event Handler Auth - An
authblock as defined below. - system
Events string[] - Specify the list of system events. Supported values are
connect,connectedanddisconnected. - user
Event stringPattern - Specify the matching event names. There are 3 kind of patterns supported:
*matches any event name,Combine multiple events with,for exampleevent1,event2, it matches eventevent1andevent2- The single event name, for example
event1, it matchesevent1.
- url_
template str - The Event Handler URL Template. Two predefined parameters
{hub}and{event}are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example:http://example.com/api/{hub}/{event}. - auth
Hub
Event Handler Auth - An
authblock as defined below. - system_
events Sequence[str] - Specify the list of system events. Supported values are
connect,connectedanddisconnected. - user_
event_ strpattern - Specify the matching event names. There are 3 kind of patterns supported:
*matches any event name,Combine multiple events with,for exampleevent1,event2, it matches eventevent1andevent2- The single event name, for example
event1, it matchesevent1.
- url
Template String - The Event Handler URL Template. Two predefined parameters
{hub}and{event}are available to use in the template. The value of the EventHandler URL is dynamically calculated when the client request comes in. Example:http://example.com/api/{hub}/{event}. - auth Property Map
- An
authblock as defined below. - system
Events List<String> - Specify the list of system events. Supported values are
connect,connectedanddisconnected. - user
Event StringPattern - Specify the matching event names. There are 3 kind of patterns supported:
*matches any event name,Combine multiple events with,for exampleevent1,event2, it matches eventevent1andevent2- The single event name, for example
event1, it matchesevent1.
HubEventHandlerAuth, HubEventHandlerAuthArgs
- Managed
Identity stringId - Specify the identity ID of the target resource.
- Managed
Identity stringId - Specify the identity ID of the target resource.
- managed
Identity StringId - Specify the identity ID of the target resource.
- managed
Identity stringId - Specify the identity ID of the target resource.
- managed_
identity_ strid - Specify the identity ID of the target resource.
- managed
Identity StringId - Specify the identity ID of the target resource.
Import
Web Pubsub Hub can be imported using the resource id, e.g.
$ pulumi import azure:webpubsub/hub:Hub example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SignalRService/webPubsub/webpubsub1/hubs/webpubsubhub1
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurermTerraform Provider.
We recommend using Azure Native.
published on Monday, Mar 9, 2026 by Pulumi
