简体   繁体   English

检查Azure Service Bus名称是否唯一

[英]Check if Azure Service Bus name is unique

I am creating an Azure Service Bus with the Fluent SDK. 我正在使用Fluent SDK创建Azure服务总线。 I want to give my service bus a specific name and increment by one if the name is unavailable. 我想给我的服务总线指定一个特定的名称,如果该名称不可用,请增加一个。 The problem I am having is that I don't actually know if the name is unavailable at the time of creation. 我遇到的问题是我实际上不知道该名称在创建时是否不可用。

I'm using this to create a service bus: 我正在使用它来创建服务总线:

var serviceBusNamespace = azure.ServiceBusNamespaces
                            .Define(serviceBusName)
                            .WithRegion(Region)
                            .WithExistingResourceGroup(resourceGroup)
                            .WithSku(NamespaceSku.Standard)
                            .Create();

If I run this code for two different resource groups using the same serviceBusName , I get a service bus created in both resources groups without error. 如果我使用相同的serviceBusName为两个不同的资源组运行此代码,则将在两个资源组中创建一个服务总线而不会出现错误。 However when I go to the Azure portal the first service bus opens fine, but I get an error saying 'Not Found' when trying to open the second. 但是,当我转到Azure门户时,第一个服务总线可以正常打开,但是在尝试打开第二个服务总线时出现错误消息“未找到”。

I understand that servicebus names must be unique across all of Azure, but 我知道服务总线名称在所有Azure中都必须是唯一的,但是

  1. Why is the Fluent SDK allowing me to create the second service bus with the same name? 为什么Fluent SDK允许我用相同的名称创建第二条服务总线?
  2. How can I check of the name is unique before creating the service bus? 创建服务总线之前,如何检查名称的唯一性?

I tried to ping the service bus URL to see if it exists. 我试图对服务总线URL进行ping操作,以查看其是否存在。 For example I tried this , for a URL like serviceBusName.servicebus.windows.net , but that failed. 例如,我为serviceBusName.servicebus.windows.net类的URL尝试过此操作 ,但是失败了。

Why is the Fluent SDK allowing me to create the second service bus with the same name? 为什么Fluent SDK允许我用相同的名称创建第二条服务总线?

You should raise this as an issue with the team that develops the library. 您应该将此问题作为开发库的团队的一个问题。 In this case, Fluent SDK is produced by .NET Libraries for Azure team. 在这种情况下,Fluent SDK是由.NET库为Azure团队生产的。 Issue tracker is available here . 问题跟踪器在这里可用。 When raising an issue, label it with Service Bus . 提出问题时,请用Service Bus标记它。

How can I check of the name is unique before creating the service bus? 创建服务总线之前,如何检查名称的唯一性?

Operation to provision a new namespace could be enqueued internally. 提供新名称空间的操作可以在内部排队。 Therefore, when you query for a namespace existence, you might get a negative response while backend is spinning it up. 因此,当查询命名空间是否存在时,后端在旋转命名空间时可能会得到否定响应。 One of the requests will succeed, while another will fail. 其中一个请求将成功,而另一个将失败。 You'd need to create and query for a result after , checking the status. 您需要检查状态之后创建并查询结果。

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

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