1

Is there a way to get the connection string of an Azure Service Bus Namespace by just supplying the namespace name?

I currently have the connection string hard-coded in the config but this will change after deployment to the next environment. I know what the namespace will be but wont have access to the portal to retrieve its connection string.

Anyone know if this is possible or if there is a better approach for this scenario?

2 Answers 2

2

In ARM Template, You can use the below code to retrieve the connection string from service bus namespace


"connectionString": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('ServiceBusNamespace_name'), 'RootManageSharedAccessKey'), '2017-04-01').primaryConnectionString]"

Sign up to request clarification or add additional context in comments.

1 Comment

how do you find out that you can access this property? "primaryConnectionString" doesn't even exist for my application service bus when I go to resources.azure.com and look under the service bus. Is there documentation on MS about getting a service bus connection string using listKeys? Just found the documentation...makes sense now. learn.microsoft.com/en-us/rest/api/servicebus/topics/…
1

It's not possible to derive Azure Service Bus namespace connection string from the namespace name solely. It would be completely insecure and anyone would be able to gain access to any namespace. There are common practices about secrets management. I'll list a few of those and you'll have to research and see what works for your scenario.

  • Environment variable - the value can change per environment, but the code is using the same environment variable to read the connection string in different environments.
  • Secret manager
  • Azure App Configuration Service - in preview, but stable and works great

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.