本文整理汇总了Python中azure.storage.queue.QueueService.generate_shared_access_signature方法的典型用法代码示例。如果您正苦于以下问题:Python QueueService.generate_shared_access_signature方法的具体用法?Python QueueService.generate_shared_access_signature怎么用?Python QueueService.generate_shared_access_signature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.queue.QueueService
的用法示例。
在下文中一共展示了QueueService.generate_shared_access_signature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_up_queue
# 需要导入模块: from azure.storage.queue import QueueService [as 别名]
# 或者: from azure.storage.queue.QueueService import generate_shared_access_signature [as 别名]
def set_up_queue(queue_name):
account_name = input('Please provide Azure account name:')
account_key = input('Please provide Azure access key:')
queue_service = QueueService(account_name, account_key)
print('Creating queue: {} ...'.format(queue_name))
try:
queue_service.create_queue(queue_name)
except AzureException as exc:
print('Cannot create queue, reason: {}'.format(exc), file=sys.stderr)
sys.exit(1)
else:
print('Queue successfully created.')
print('Generating SAS token...')
expiry_date = datetime.date.today() + datetime.timedelta(days=30)
print('SAS token will expire in', str(expiry_date))
access_policy = AccessPolicy(
expiry=str(expiry_date),
permission=(
QueueSharedAccessPermissions.READ +
QueueSharedAccessPermissions.ADD +
QueueSharedAccessPermissions.PROCESS
),
)
sas_token = queue_service.generate_shared_access_signature(
queue_name, SharedAccessPolicy(access_policy),
)
print('Generated SAS token:', sas_token)
print('Please use above token in QueueManager.')