ServiceBusAdministrationClient.CreateRuleAsync Method

Definition

Adds a new rule to the subscription under given topic.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.RuleProperties>> CreateRuleAsync (string topicName, string subscriptionName, Azure.Messaging.ServiceBus.Administration.CreateRuleOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateRuleAsync : string * string * Azure.Messaging.ServiceBus.Administration.CreateRuleOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.RuleProperties>>
override this.CreateRuleAsync : string * string * Azure.Messaging.ServiceBus.Administration.CreateRuleOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.RuleProperties>>
Public Overridable Function CreateRuleAsync (topicName As String, subscriptionName As String, options As CreateRuleOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of RuleProperties))

Parameters

topicName
String

The topic name relative to the service namespace base address.

subscriptionName
String

The name of the subscription.

options
CreateRuleOptions

A CreateRuleOptions object describing the attributes with which the messages are matched and acted upon.

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

RuleProperties of the recently created rule.

Exceptions

A subscription with the same name exists under the same service namespace.

The operation times out. The timeout period is initialized through the ServiceBusAdministrationClientOptions class (see Retry property). You may need to increase the value of timeout to avoid this exception if the timeout value is relatively low.

Either the specified size in the description is not supported or the maximum allowable quota has been reached. You must specify one of the supported size values, delete existing entities, or increase your quota size.

The server is busy. You should wait before you retry the operation.

The topic name, subscription name, or options instance is null.

The topic or subscription name name exceeds the maximum allowed length.

The topic or subscription name is otherwise invalid.

Insufficient permission to perform this operation. You should check to ensure that your ServiceBusAdministrationClient has the necessary claims to perform this operation. https://docs.microsoft.com/azure/service-bus-messaging/service-bus-sas#rights-required-for-service-bus-operations

  • A rule with the same name exists under the subscription. The Reason will be set to MessagingEntityAlreadyExists in this case.
  • The operation timed out. The Reason will be set to ServiceTimeout in this case.
  • Either the specified size of the entity is not supported or the maximum allowable quota has been reached. You must specify one of the supported size values, delete existing entities, or increase your quota size. The failure reason will be set to QuotaExceeded in this case.
  • The server is busy. You should wait before you retry the operation. The failure reason will be set to ServiceBusy in this case.
  • An internal error or unexpected exception occurs. The failure reason will be set to GeneralError in this case.

Applies to