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.
- New-AzWebPubSub- Creates a new Azure Web PubSub service.
- Get-AzWebPubSub- Retrieves information about one or more Azure Web PubSub services.
- Update-AzWebPubSub- Updates an existing Azure Web PubSub service.
- Remove-AzWebPubSub- Deletes an Azure Web PubSub service.
- Get-AzWebPubSubKey- Retrieves the access keys for an Azure Web PubSub service.
- New-AzWebPubSubHub- Creates a new hub for an Azure Web PubSub service.
- Get-AzWebPubSubHub- Retrieves information about hubs associated with an Azure Web PubSub service.
- Remove-AzWebPubSubHub- Removes a hub from an Azure Web PubSub service.
- Get-AzWebPubSubServiceEndpoint- Retrieves the endpoint for an Azure Web PubSub service.
- Test-AzWebPubSubConnectivity- Checks if it's possible to connect to an Azure Web PubSub service.
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"