Azure Service Bus Cmdlets Overview

The Azure Service Bus PowerShell module provides a rich set of cmdlets for managing your Service Bus namespaces, queues, topics, subscriptions, rules, and authorization policies. These cmdlets enable automation of deployment, configuration, and monitoring tasks.

This documentation provides detailed information on each cmdlet, including its purpose, parameters, and examples.

Queue Cmdlets

New-AzServiceBusQueue

Creates a new Service Bus queue.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the queue to create.
  • -MaxDeliveryCount: The maximum number of times a message can be delivered before it is dead-lettered.
  • -DefaultMessageTimeToLive: The default lifespan of a message.
  • -LockDuration: The duration of a lock on a message.
  • -RequiresDuplicateDetection: Specifies whether duplicate detection is enabled for the queue.

Example:

New-AzServiceBusQueue -NamespaceName "MyNamespace" -Name "MyQueue" -MaxDeliveryCount 10 -DefaultMessageTimeToLive "1.00:00:00"

Get-AzServiceBusQueue

Retrieves one or more Service Bus queues.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the queue to retrieve. (Optional)

Example:

Get-AzServiceBusQueue -NamespaceName "MyNamespace"

Remove-AzServiceBusQueue

Deletes a Service Bus queue.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the queue to delete.

Example:

Remove-AzServiceBusQueue -NamespaceName "MyNamespace" -Name "MyQueue"

Topic Cmdlets

New-AzServiceBusTopic

Creates a new Service Bus topic.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the topic to create.
  • -MaxSizeInMB: The maximum size of the topic in MB.

Example:

New-AzServiceBusTopic -NamespaceName "MyNamespace" -Name "MyTopic" -MaxSizeInMB 1024

Get-AzServiceBusTopic

Retrieves one or more Service Bus topics.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the topic to retrieve. (Optional)

Example:

Get-AzServiceBusTopic -NamespaceName "MyNamespace"

Remove-AzServiceBusTopic

Deletes a Service Bus topic.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the topic to delete.

Example:

Remove-AzServiceBusTopic -NamespaceName "MyNamespace" -Name "MyTopic"

Rule Cmdlets

New-AzServiceBusSubscriptionRule

Creates a new rule for a Service Bus topic subscription.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -TopicName: The name of the topic.
  • -SubscriptionName: The name of the subscription.
  • -Name: The name of the rule.
  • -FilterType: The type of filter (e.g., 'SqlFilter', 'CorrelationFilter').
  • -FilterParameter: The filter expression or parameters.

Example:

New-AzServiceBusSubscriptionRule -NamespaceName "MyNamespace" -TopicName "MyTopic" -SubscriptionName "MySubscription" -Name "HighPriorityRule" -FilterType "SqlFilter" -FilterParameter "Priority = 'High'"

Get-AzServiceBusSubscriptionRule

Retrieves one or more rules for a Service Bus topic subscription.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -TopicName: The name of the topic.
  • -SubscriptionName: The name of the subscription.
  • -Name: The name of the rule to retrieve. (Optional)

Example:

Get-AzServiceBusSubscriptionRule -NamespaceName "MyNamespace" -TopicName "MyTopic" -SubscriptionName "MySubscription"

Remove-AzServiceBusSubscriptionRule

Deletes a rule from a Service Bus topic subscription.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -TopicName: The name of the topic.
  • -SubscriptionName: The name of the subscription.
  • -Name: The name of the rule to delete.

Example:

Remove-AzServiceBusSubscriptionRule -NamespaceName "MyNamespace" -TopicName "MyTopic" -SubscriptionName "MySubscription" -Name "HighPriorityRule"

Authorization Cmdlets

New-AzServiceBusAuthorizationRule

Creates a new authorization rule for a Service Bus namespace, queue, or topic.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the authorization rule.
  • -Rights: An array of authorization rights (e.g., 'Listen', 'Send', 'Manage').
  • -QueueName: The name of the queue. (Optional, if applying to a queue)
  • -TopicName: The name of the topic. (Optional, if applying to a topic)

Example:

New-AzServiceBusAuthorizationRule -NamespaceName "MyNamespace" -Name "ListenerRule" -Rights @("Listen")

Get-AzServiceBusAuthorizationRule

Retrieves one or more authorization rules.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the authorization rule to retrieve. (Optional)
  • -QueueName: The name of the queue. (Optional)
  • -TopicName: The name of the topic. (Optional)

Example:

Get-AzServiceBusAuthorizationRule -NamespaceName "MyNamespace" -TopicName "MyTopic"

Remove-AzServiceBusAuthorizationRule

Deletes an authorization rule.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -Name: The name of the authorization rule to delete.
  • -QueueName: The name of the queue. (Optional)
  • -TopicName: The name of the topic. (Optional)

Example:

Remove-AzServiceBusAuthorizationRule -NamespaceName "MyNamespace" -Name "ListenerRule"

Shared Access Signature (SAS) Cmdlets

Get-AzServiceBusKey

Retrieves the access keys for a Service Bus authorization rule.

Parameters:
  • -NamespaceName: The name of the Service Bus namespace.
  • -AuthorizationRuleName: The name of the authorization rule.
  • -QueueName: The name of the queue. (Optional)
  • -TopicName: The name of the topic. (Optional)

Example:

Get-AzServiceBusKey -NamespaceName "MyNamespace" -AuthorizationRuleName "ManageRule"