您可以使用代码为该队列创建一个service SAS token
(例如,名为 queueA 的队列),然后将其与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);
更多细节可以参考这篇文章(它是用于blob存储,但你可以很容易地修改它用于队列存储)。