如何为Azure队列设置共享访问策略?

时间:2012-09-06 14:08:17

标签: security azure queue

显然,可以使用共享访问策略来控制对Azure队列的访问。此处的示例http://msdn.microsoft.com/en-us/library/windowsazure/hh508996确认了这一点,但后来仅提供了blob共享访问策略的示例。有没有人对队列(和表)如何实现相同的参考?

2 个答案:

答案 0 :(得分:2)

您可以在Windows Azure存储博客上找到完整的示例:Introducing Table SAS (Shared Access Signature), Queue SAS and update to Blob SAS。以下是将策略分配给队列的部分:

// Create the GC queue SAS policy.
QueuePermissions gcQueuePermissions = new QueuePermissions();
SharedAccessQueuePolicy gcQueuePolicy = new SharedAccessQueuePolicy()
{
    // Providing the max duration
    SharedAccessExpiryTime = DateTime.MaxValue,
    // Permission is granted to process queue messages.
    Permissions = SharedAccessQueuePermissions.ProcessMessages
};

// Associate the above policy with a signed identifier
gcQueuePermissions.SharedAccessPolicies.Add(
    gcPolicySignedIdentifier,
    gcQueuePolicy);

// The below call will result in a Set Queue ACL request to be sent to 
// Windows Azure Storage in order to store the policy and associate it with the 
// "GCAccessPolicy" signed identifier that will be referred to
// by the generated SAS token
this.gcQueue.SetPermissions(gcQueuePermissions);

答案 1 :(得分:0)

announcement post for table SAS (特别是样本的SAS令牌生成器部分)是否可以帮助您?在我看来,SAS可以从SDK 1.7开始在表和队列中使用。