一次部署具有多个主题和队列的ServiceBus [英] Deploy ServiceBus with multiple Topics and Queues at once

查看:109
本文介绍了一次部署具有多个主题和队列的ServiceBus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用Servicebus和其他Azure功能还很陌生.在Azure门户上手动创建Servicebus之后,我尝试弄清楚如何自动实现.经过一段时间的阅读,我认为使用天蓝色资源管理器应该是可行的方法.仅部署一个主题没什么大不了的.但是我找不到一个示例,该示例显示了如何一次部署多个主题和队列.还是我使用错误的方法?

I'm fairly new to using the servicebus and other Azure features. After creating a servicebus manually on the Azure portal, I try to figure out how this can be achieved automatically. After a while of reading I thought that using the azure resource manager should be the way to go. Deploying just one topic is no big deal. But I can't find an example, that shows how to deploy multiple topics and queues at once. Or am I on the wrong approach?

感谢您的回答! 赫尔穆特

Thanks for your answers! Helmut

推荐答案

我们的工作很简单(我看到其他团队也在这样做)很简单:当您的生产者/消费者应用程序启动时,它会检查是否需要队列/主题/订阅存在,否则创建它们.

What we do (and I saw other teams doing the same) is simple: when your producer/consumer application starts, it checks if required queues/topics/subscriptions exist, and creates them otherwise.

因此,我们从C#代码创建所有服务总线实体,这也为选项提供了充分的灵活性.

So we create all Service Bus entities from C# code, which also gives the full flexibility for options.

代码示例:

var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
if (!namespaceManager.TopicExists(topicName))
{
    namespaceManager.CreateTopic(new TopicDescription(topicName));
    namespaceManager.CreateSubscription(
        new SubscriptionDescription(topicName, subscriptionName));
}

这并不是说您的ARM方法是对还是错,只是为了给出一个简单的选择.

That's not to say your ARM approach is wrong or bad, just to give a simple alternative.

这篇关于一次部署具有多个主题和队列的ServiceBus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆