简体   繁体   English

Azure Service Bus的状态更改

[英]Status change of Azure Service Bus

I have created a SB in the azure portal. 我已经在azure门户中创建了一个SB。 By default the status is showing as Active. 默认情况下,状态显示为“活动”。 Let me have a scenario where i want to change the status of this SB, any idea on how to do that? 让我有一个情况,我想更改此SB的状态,有关如何执行此操作的任何想法? Any pointers will be very helpful. 任何指针将非常有帮助。 We have 2 service bus and one needs to be active at a time. 我们有2条服务总线,一次需要激活一条。 So how can we manage that? 那么我们该如何处理呢?

By default the status is showing as Active. 默认情况下,状态显示为“活动”。 Let me have a scenario where i want to change the status of this SB, any idea on how to do that? 让我有一个情况,我想更改此SB的状态,有关如何执行此操作的任何想法?

Service Bus works as a container or a namespace. 服务总线充当容器或名称空间。 The status of Azure Service Bus is internal used, we can't change it on Azure portal or using any API. Azure Service Bus的状态为内部使用,我们无法在Azure门户上或使用任何API对其进行更改。

As @Sean Feldman said, we can only enable or disable the entities(queues or topics) in the Service Bus in the properties panel. 正如@Sean Feldman所说,我们只能在属性面板的Service Bus中启用或禁用实体(队列或主题)。

在此处输入图片说明

To disable all the queues and topics in a Service Bus, you could using following code. 要禁用服务总线中的所有队列和主题,可以使用以下代码。

string connectionString = "your connection string of service bus";
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

IEnumerable<QueueDescription> queueList = namespaceManager.GetQueues();

foreach (QueueDescription qd in queueList)
{
    qd.Status = EntityStatus.Disabled;
    namespaceManager.UpdateQueue(qd);
}

IEnumerable<TopicDescription> topicList = namespaceManager.GetTopics();

foreach (TopicDescription td in topicList)
{
    td.Status = EntityStatus.Disabled;
    namespaceManager.UpdateTopic(td);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM