简体   繁体   中英

In Azure's Python service bus SDK, how do I query the shared access policies of a namespace?

I'm using Python 3.8 and Azure's service bus SDK (azure-servicebus==0.50.3). Currently, I can use the below code to get a shared access policy rule (and key/value) for a specific topic within a namespace

from azure.mgmt.servicebus import ServiceBusManagementClient
...
    self._sb_client = ServiceBusManagementClient(credential, subscription)
    ...
        rule = self._sb_client.topics.list_keys(
            self._resource_group_name,
            self._namespace,
            self._topic_name,
            SB_SAS_POLICY_LISTEN
        )

How do I make the logic a little more general so that I can query policies at the namespace level? We have a root shared access policy and I wanted to see if there's a programmatic way to get the rule similar to the above. I've tried excluding the topic parameter, but I'm unable it is required.

Aha. It appears you're specifically using azure-mgmt-servicebus for the tooling you're leveraging, which is exactly the right thing, and has the functionality you're looking for:

There is a comparable list_keys method present on the namespace as well as on a given topic, which would be called via client.namespaces.list_keys( .

Don't hesitate to shout if I've misunderstood or if any of this is unclear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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