简体   繁体   English

创建和删除Azure服务总线主题的最低权限?

[英]Minimum Permissions for Creating and Deleting Subscriptions to an Azure Service Bus Topic?

I am creating an app which needs to create and delete subscriptions to an already created topic in azure service bus. 我正在创建一个应用程序,该应用程序需要在azure服务总线中创建和删除对已创建主题的订阅。

does my share access token need manage permissions on the topic to create and delete subscriptions? 我的共享访问令牌是否需要该主题的管理权限才能创建和删除订阅? I've does some preliminary googling, and none of the articles I can find shows the correlation of the three roles (manage, send, listen) to the subscription entity. 我已经进行了一些初步的谷歌搜索,但我找不到的文章都没有显示这三个角色(管理,发送,监听)与订阅实体的相关性。

Thanks! 谢谢!

update I have created a Shared Access Policy directly on the topic, then I have the following code written to reach out to the Topic, create subscriptions, then cancel/dispose of them via an IDisposable interface: 更新我已经直接在该主题上创建了共享访问策略,然后编写了以下代码以访问该主题,创建订阅,然后通过IDisposable接口取消/处置它们:

public class SubscriptionHandler : IDisposable
{
    protected NamespaceManager SubManager { get; set; }
    protected SubscriptionDescription SubDetails { get; set; }
    public SubscriptionClient Client { get; }

    public SubscriptionHandler(AuthDetails details)
    {
        try
        {
            var connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            SubManager = NamespaceManager.CreateFromConnectionString(connectionString);
            SubDetails = new SubscriptionDescription("topic", $"record{details.ID}.Other{details.OtherID}");
            if (!SubManager.SubscriptionExists(SubDetails.TopicPath, SubDetails.Name))
            {   //setting subscription to receive all bookings that are for the given businessID
                SubManager.CreateSubscription(SubDetails, new SqlFilter($"ID = {details.ID}"));
            }

            Client = SubscriptionClient.CreateFromConnectionString(connectionString, SubDetails.TopicPath, SubDetails.Name);
        }catch (Exception ex)
        {
            throw;
        }
    }

    public void Dispose()
    {
        if(Client != null)
        {
            Client.Close(); // telling subscription we are no longer going to recieve messages
        }

        if (SubManager != null && SubManager.SubscriptionExists(SubDetails.TopicPath, SubDetails.Name))
        {
            SubManager.DeleteSubscription(SubDetails.TopicPath, SubDetails.Name);
        }
    }

however, I am still getting unauthorized exception thrown on the 但是,我仍然收到未经授权的异常

SubManager.CreateSubscription(SubDetails, new SqlFilter($"ID = {details.ID}")); SubManager.CreateSubscription(SubDetails,new SqlFilter($“ ID = {details.ID}”))); call. 呼叫。 I copied the connection string from the SharedAccessPolicy connection strings, then removed the EntityPath name value pair.... What am I doing wrong? 我从SharedAccessPolicy连接字符串中复制了连接字符串,然后删除了EntityPath名称值对。...我在做什么错?

does my share access token need manage permissions on the topic to create and delete subscriptions? 我的共享访问令牌是否需要该主题的管理权限才能创建和删除订阅?

As the official document mentioned about Rights required for Service Bus operations , the Create a subscription and Delete subscription operations need Manage permission on the topic. 正如有关服务总线操作所需权限的正式文档所述,“ Create a subscription和“ Delete subscription操作需要对该主题具有“ 管理”权限。

Without the Manage permission, you would get the 401 response as follows when you deal with the Create/Delete subscription operation: 没有“管理”权限,当您处理“创建/删除”订阅操作时,将得到如下所示的401响应:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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