0

Is it possible to programmatically create a ServiceBus namspace, create identities, assign Send/Listen permissions, etc?

I found the following SO question from two years ago but I suspect things have changed in the mean time and the answer might be different.

Community
  • 1
  • 1
desautelsj
  • 3,587
  • 4
  • 37
  • 55

1 Answers1

3

Here is how you can create it using the Azure PowerShell cmdlets (for example, in East US):

New-AzureSBNamespace -Name "[YOUR SB NAMESPACE NAME]" -Location "East US"

There is always the REST API. I've not used it for Service Bus or I would give you a sample. Instead, here is the link to it for your reference. :)

http://msdn.microsoft.com/en-us/library/azure/jj856303.aspx

There is also a client library (in preview) that you can use if you want the C# experience.

enter image description here

Here is sample code using the Service Bus Management Library:

        // Get this from the portal
        var subscriptionId = "5f830156-0000-0000-0000-000000000000";
        // Get this from your .publishsettings file
        var managementCert = "MIIKFAI...really long string of base64...==";

        var creds = new CertificateCloudCredentials(
            subscriptionId,
            new X509Certificate2(Convert.FromBase64String(managementCert)));

        ServiceBusManagementClient sbMgmtClient = new ServiceBusManagementClient(creds);
        sbMgmtClient.Namespaces.Create("[YOUR SB NAMESPACE NAME]", "East US");
Rick Rainey
  • 11,096
  • 4
  • 30
  • 48
  • These two suggestions where mentioned in the answers to SO question I linked to. I was hoping there was something I could use directly in my C# code without hand coding REST calls. – desautelsj Oct 03 '14 at 21:31
  • Apparently there is also a management library (in preview). I just updated the answer to include it. – Rick Rainey Oct 03 '14 at 22:25
  • Very interesting. I didn't know about this library, I will have a look. – desautelsj Oct 03 '14 at 22:47
  • I was able to create a Namespace in only a few minutes with the library you suggested. Excellent. Now I need to figure out how to configure the Rule Groups and the Identities... – desautelsj Oct 03 '14 at 23:01