我对使用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
发布评论