Azure Web PubSub Cmdlets

This section provides comprehensive documentation for Azure PowerShell cmdlets used to manage Azure Web PubSub services.

Overview

Azure Web PubSub is a fully managed service that enables developers to build real-time messaging applications using WebSockets and publish-subscribe patterns. The Azure PowerShell module provides a powerful way to automate the deployment and management of your Web PubSub resources.

Available Cmdlets

Below is a list of common cmdlets for managing Azure Web PubSub. For detailed syntax and parameters, please refer to the individual cmdlet help pages.

Common Usage Examples

Creating a Web PubSub Service

# Sign in to your Azure account
Login-AzAccount

# Set your subscription context
Set-AzContext -SubscriptionId "YOUR_SUBSCRIPTION_ID"

# Define resource group and service name
$resourceGroupName = "MyWebPubSubRG"
$webPubSubName = "myuniqueazwebpubsub"

# Create a new resource group if it doesn't exist
if (-not (Get-AzResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue)) {
    New-AzResourceGroup -Name $resourceGroupName -Location "East US"
}

# Create the Azure Web PubSub service
New-AzWebPubSub -Name $webPubSubName -ResourceGroupName $resourceGroupName -Location "East US" -Sku "Standard_P1" -UnitCount 1

Retrieving Service Details

# Get all Web PubSub services in a resource group
Get-AzWebPubSub -ResourceGroupName "MyWebPubSubRG"

# Get a specific Web PubSub service
Get-AzWebPubSub -Name "myuniqueazwebpubsub" -ResourceGroupName "MyWebPubSubRG"

Managing Hubs

# Create a hub
New-AzWebPubSubHub -Name "chatHub" -WebPubSubName "myuniqueazwebpubsub" -ResourceGroupName "MyWebPubSubRG"

# Get all hubs for a service
Get-AzWebPubSubHub -WebPubSubName "myuniqueazwebsub" -ResourceGroupName "MyWebPubSubRG"

# Remove a hub
Remove-AzWebPubSubHub -Name "chatHub" -WebPubSubName "myuniqueazwebpubsub" -ResourceGroupName "MyWebPubSubRG"

Further Resources