【问题标题】:Azure Storage - Restrict IP in SAS when using Stored Access PolicyAzure 存储 - 使用存储访问策略时限制 SAS 中的 IP
【发布时间】:2021-05-01 14:43:09
【问题描述】:

在 Azure 存储帐户中,我已开始使用 SAS(共享访问签名)和 SAP(存储访问策略)来保护对 Azure 存储队列中特定队列的访问。

我想要实现的是将特定 IP 限制到特定队列(1.1.1.1 可以访问 queueA,但 2.2.2.2 不能)。

目前我已经看到我可以使用存储帐户级别的 SAS 来限制 IP,以及在门户的网络部分中设置限制。这些都不太合适。

(我知道以下问题,但对尝试设置存储帐户网络的回复不满意 - Is it possible to filtre on IP address for Azure STORAGE SAS with ACCESS POLICY?

谢谢

【问题讨论】:

    标签: azure azure-storage azure-storage-queues shared-access-signatures


    【解决方案1】:

    您可以使用代码为该队列(例如名为 queueA 的队列)创建一个service SAS token,然后将其与Stored Access Policy 关联。

    例如(请修改代码以满足您的需要):

            QueueClient queueClient = new QueueClient(connectionString, "queueA");
    
            //create a service SAS 
            QueueSasBuilder sasBuilder = new QueueSasBuilder()
            {
                QueueName = "queueA",
    
                //set the ip here
                IPRange = new SasIPRange(IPAddress.Parse("172.16.0.1"))
            };
    
            //associate the service SAS with the Stored Access Policy
            sasBuilder.Identifier = storedPolicyName;
    
            //then you can use this uri with sas token to operate this queue
            Uri sasUri = queueClient.GenerateSasUri(sasBuilder);
    

    更多细节可以参考this article(用于blob存储,但可以方便修改为队列存储)。

    【讨论】:

      猜你喜欢
      • 2018-04-24
      • 2019-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-11
      • 2016-12-10
      • 2018-05-05
      相关资源
      最近更新 更多