skip to Main Content

I’m trying to create a topic using ServiceBusAdministrationClient connected through a namespace’s root manage access key
(com.azure:azure-messaging-servicebus:7.8.0)

def createOptions = new CreateTopicOptions()
def authRule = new SharedAccessAuthorizationRule(authRuleName, [AccessRights.SEND, AccessRights.LISTEN])
createOptions.authorizationRules.add(authRule)
def topicProps = administrationClient.createTopic(topicName, createOptions)

but there are no AuthorizationRules associated with the topic.
I did the same thing when creating a queue and it worked.
Any ideas what I might be missing?

2

Answers


  1. There are two different ways to do the required thing.

    1. Azure Active Directory (ADD) – AuthorizationRules
    2. Shared Access Signature. Shared access signature

    There is a professional documentation to the series of steps to be followe.

    Tutorial: Update inventory using Azure portal and topics/subscriptions

    Login or Signup to reply.
  2. For the authorization rule, you need to use Azure Resource Management library
    Below is a sample to create an authorization rule

    final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
    
    final TokenCredential credential =
        new DefaultAzureCredentialBuilder()
            .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
            .build();
    
    var azureResourceManager =
        AzureResourceManager.configure()
            .withLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)
            .authenticate(credential, profile)
            .withSubscription("subscription");
    
    ServiceBusManager manager = azureResourceManager.serviceBusNamespaces().manager();
    
    SBAuthorizationRuleInner authorizationRule =
        manager
            .serviceClient()
            .getTopics()
            .createOrUpdateAuthorizationRule(
                "resourceGroupName", "namespaceName", "topicName", "authorizationRuleName");
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search