Check if Azure Service Bus name is unique

301 views Asked by At

I am creating an Azure Service Bus with the Fluent SDK. 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. 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.

I understand that servicebus names must be unique across all of Azure, but

  1. Why is the Fluent SDK allowing me to create the second service bus with the same name?
  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. For example I tried this, for a URL like serviceBusName.servicebus.windows.net, but that failed.

1

There are 1 answers

1
Sean Feldman On

Why is the Fluent SDK allowing me to create the second service bus with the same name?

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. Issue tracker is available here. When raising an issue, label it with 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.