Share via


ManagementClient.CreateRuleAsync Method

Definition

Adds a new rule to the subscription under given topic.

public virtual System.Threading.Tasks.Task<Microsoft.Azure.ServiceBus.RuleDescription> CreateRuleAsync (string topicPath, string subscriptionName, Microsoft.Azure.ServiceBus.RuleDescription ruleDescription, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateRuleAsync : string * string * Microsoft.Azure.ServiceBus.RuleDescription * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.ServiceBus.RuleDescription>
override this.CreateRuleAsync : string * string * Microsoft.Azure.ServiceBus.RuleDescription * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Azure.ServiceBus.RuleDescription>
Public Overridable Function CreateRuleAsync (topicPath As String, subscriptionName As String, ruleDescription As RuleDescription, Optional cancellationToken As CancellationToken = Nothing) As Task(Of RuleDescription)

Parameters

topicPath
String

The topic path relative to the service namespace base address.

subscriptionName
String

The name of the subscription.

ruleDescription
RuleDescription

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

cancellationToken
CancellationToken

Returns

RuleDescription of the recently created rule.

Exceptions

Subscription or rule description is null.

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

The operation times out. The timeout period is initialized through the ServiceBusConnection class. You may need to increase the value of timeout to avoid this exception if the timeout value is relatively low.

No sufficient permission to perform this operation. You should check to ensure that your ManagementClient has the correct TokenProvider credentials to perform this operation.

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.

An internal error or unexpected exception occurs.

Applies to