我可以使用 Powershell 启用/禁用 Azure 服务总线主题吗

Can I enable / Disable an Azure Service Bus Topic using Powershell

我花了几个小时搜索使用 Powershell 禁用我的 Azure 服务总线主题的解决方案。

这样做的背景是我们想强制手动故障转移到我们的其他区域。

显然我可以在 Portal 中点击: 但我想要一个脚本来执行此操作。

这是我目前的尝试:

任何帮助都会很棒。

假设您确定您的 $topic 包含完整描述,请修改数组中的 status 参数,然后使用 UpdateTopic 方法将其展开。恐怕我目前无法测试这个。

$topic.Status = "Disabled"
$topicdesc = $NamespaceManager.UpdateTopic($topic)

我认为您不需要为 Status 设置实体类型,也不需要在循环中的每行代码后使用分号。

参考文献

PowerShell 服务总线创建示例脚本(这似乎是基于它):https://blogs.msdn.microsoft.com/paolos/2014/12/02/how-to-create-service-bus-queues-topics-and-subscriptions-using-a-powershell-script/

UpdateTopic 方法:https://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.namespacemanager.updatetopic.aspx

附加说明:请不要截屏代码 - 将其粘贴进去。我宁愿复制粘贴也不愿输入内容。