共用方式為


ServiceBusAdministrationClient.CreateSubscriptionAsync Method

Definition

Overloads

CreateSubscriptionAsync(CreateSubscriptionOptions, CancellationToken)

Creates a new subscription within a topic in the service namespace with the given name.

CreateSubscriptionAsync(CreateSubscriptionOptions, CreateRuleOptions, CancellationToken)

Creates a new subscription within a topic with the provided default rule.

CreateSubscriptionAsync(String, String, CancellationToken)

Creates a new subscription within a topic in the service namespace with the given name.

CreateSubscriptionAsync(CreateSubscriptionOptions, CancellationToken)

Source:
ServiceBusAdministrationClient.cs
Source:
ServiceBusAdministrationClient.cs

Creates a new subscription within a topic in the service namespace with the given name.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.SubscriptionProperties>> CreateSubscriptionAsync (Azure.Messaging.ServiceBus.Administration.CreateSubscriptionOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateSubscriptionAsync : Azure.Messaging.ServiceBus.Administration.CreateSubscriptionOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.SubscriptionProperties>>
override this.CreateSubscriptionAsync : Azure.Messaging.ServiceBus.Administration.CreateSubscriptionOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.SubscriptionProperties>>
Public Overridable Function CreateSubscriptionAsync (options As CreateSubscriptionOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of SubscriptionProperties))

Parameters

options
CreateSubscriptionOptions

A SubscriptionProperties object describing the attributes with which the new subscription will be created.

cancellationToken
CancellationToken

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

Returns

The SubscriptionProperties of the newly created subscription.

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 options instance is null.

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

  • A subscription with the same name exists under the same service namespace. 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.

Remarks

Throws if a subscription already exists. By default, A "pass-through" filter is created for this subscription, which means it will allow all messages to go to this subscription. The name of the filter is represented by DefaultRuleName. CreateSubscriptionAsync(CreateSubscriptionOptions, CreateRuleOptions, CancellationToken) for creating subscription with a different filter.

Applies to

CreateSubscriptionAsync(CreateSubscriptionOptions, CreateRuleOptions, CancellationToken)

Source:
ServiceBusAdministrationClient.cs
Source:
ServiceBusAdministrationClient.cs

Creates a new subscription within a topic with the provided default rule.

public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.SubscriptionProperties>> CreateSubscriptionAsync (Azure.Messaging.ServiceBus.Administration.CreateSubscriptionOptions options, Azure.Messaging.ServiceBus.Administration.CreateRuleOptions rule, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateSubscriptionAsync : Azure.Messaging.ServiceBus.Administration.CreateSubscriptionOptions * Azure.Messaging.ServiceBus.Administration.CreateRuleOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.SubscriptionProperties>>
override this.CreateSubscriptionAsync : Azure.Messaging.ServiceBus.Administration.CreateSubscriptionOptions * Azure.Messaging.ServiceBus.Administration.CreateRuleOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Messaging.ServiceBus.Administration.SubscriptionProperties>>
Public Overridable Function CreateSubscriptionAsync (options As CreateSubscriptionOptions, rule As CreateRuleOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of SubscriptionProperties))

Parameters

options
CreateSubscriptionOptions

A SubscriptionProperties object describing the attributes with which the new subscription will be created.

rule
CreateRuleOptions

A RuleProperties object describing the default rule. If null, then pass-through filter with name DefaultRuleName will be created.

cancellationToken
CancellationToken

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

Returns

The SubscriptionProperties of the newly created subscription.

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 options instance is null.

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

  • A subscription with the same name exists under the same service namespace. 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.

Remarks

Throws if a subscription already exists.

Applies to

CreateSubscriptionAsync(String, String, CancellationToken)

Source:
ServiceBusAdministrationClient.cs
Source:
ServiceBusAdministrationClient.cs

Creates a new subscription within a topic in the service namespace with the given name.

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

Parameters

topicName
String

The name of the topic relative to the service namespace base address.

subscriptionName
String

The name of the subscription.

cancellationToken
CancellationToken

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

Returns

The SubscriptionProperties of the newly created subscription.

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 or subscription name is null or empty.

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://learn.microsoft.com/azure/service-bus-messaging/service-bus-sas#rights-required-for-service-bus-operations

  • A subscription with the same name exists under the same service namespace. 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.

Remarks

Throws if a subscription already exists. SubscriptionProperties for default values of subscription description. By default, A "pass-through" filter is created for this subscription, which means it will allow all messages to go to this subscription. The name of the filter is represented by DefaultRuleName. CreateSubscriptionAsync(CreateSubscriptionOptions, CreateRuleOptions, CancellationToken) for creating subscription with a different filter.

Applies to