如何在创建队列后为 Azure 服务总线队列或主题启用重复消息检测

How to Enable duplicate message detection for an Azure Service Bus queue or a topic After Queue has been created

有人可以告诉我是否可以在创建队列后 enable/update 具有重复消息检测的服务队列吗?

以下link描述了如何在创建队列时启用重复消息检测。

https://docs.microsoft.com/en-us/azure/service-bus-messaging/enable-duplicate-detection 但是我没有看到任何关于如何更新现有队列以允许重复消息检测的信息……或者我找对地方了吗?

您链接到的文章在第一段之后有一个很大的紫色 注意 块。它说明了两件事。第二个语句是:

You can't enable or disable duplicate detection after the queue or topic is created. You can only do so at the time of creating the queue or topic.

这意味着您无法更新现有队列以允许重复消息检测。

编辑:
对上面的一个小补充: az servicebus queue update Azure CLI command--enable-duplicate-detection 参数。然而,尝试使用它时,returns 一个带有 SubCode 40000 和特定错误消息的 BadRequest。

查看 Service Bus Resource Manager exceptions - Error: Bad Request,它说明如下:

Error message Description Recommendation
SubCode=40000. The value for the 'requiresDuplicateDetection' property of an existing Queue(or Topic) cannot be changed. The value for the 'requiresDuplicateDetection' property of an existing Queue(or Topic) cannot be changed. Duplicate detection must be enabled/disabled at the time of entity creation. The duplicate detection configuration parameter cannot be changed after creation.

编辑:
根据上面链接的异常文档(在 Bad Request 下,table 中的倒数第二项),在创建过程中还需要指定 RequiresSessions

Support for sessions should be enabled at the time of entity creation. Once created, you cannot enable/disable sessions on an existing entity (queue or subscription)