使用PowerShell创建Azure Storage的SAS Token访问Azure Blob文件
Azure的存储包含Storage Account、Container、Blob等具体的关系如下:

我们常用的blob存储,存放在Storage Account的Container里面。
目前有三种方式可以把Blob里的内容共享给其他用户,这三种方式是:
1.把Container的属性设置为公共容器

2.把Blob属性设置为公共公共Blob
设置好后,blob就可以通过wget的方式下载下来。
3.通过SAS Token的方式实现在一定时间段内的文件共享
SAS是shared access signature (SAS),可以实现文件共享。

SAS Provider Service通过旁路的方式生成SAS的token,客户通过这个SAS Token实现在一定时间内,一定权限的访问。
下面将采用powershell的方式生成SAS Token,给客户访问的权限。
有一个文件:
Get-AzureStorageBlob -Container hengweisoft -Blob googlechrome.dmg
Container Uri: https://portalvhds6mlqtd15wqmm7.blob.core.chinacloudapi.cn/hengweisoft
Name BlobType Length ContentType LastModified SnapshotTime
---- -------- ------ ----------- ------------ ------------
googlechrome.dmg BlockBlob 65936251 application/octet-stream 2015/7/6 8:09:00 +00:00
其中hengweisoft这个Container是private的Container。
$keys = Get-AzureStorageKey -StorageAccountName portalvhds6mlqtd15wqmm7
$ctx = New-AzureStorageContext -StorageAccountName portalvhds6mlqtd15wqmm7 -StorageAccountKey $keys.Primary
$startTime = Get-Date
$endTime = $startTime.AddHours(2.0)
New-AzureStorageBlobSASToken -Container hengweisoft -Blob googlechrome.dmg -context $ctx -Permission rwd -StartTime $startTime -ExpiryTime $endTime
通过这个命令可以生成一串SAS的Token:
?sv=2015-02-21&sr=b&sig=Ifn6JFOinaLQpYGKCKsYiUieQ58WdExxV2Z52Nx%2Fdjs%3D&st=2016-02-05T09%3A36%3A57Z&se=2016-02-05T11%3A36%3A57Z&sp=rwd
将这一串Token连接到Blob的URL上:
https://portalvhds6mlqtd15wqmm7.blob.core.chinacloudapi.cn/hengweisoft/googlechrome.dmg?sv=2015-02-21&sr=b&sig=Ifn6JFOinaLQpYGKCKsYiUieQ58WdExxV2Z52Nx%2Fdjs%3D&st=2016-02-05T09%3A36%3A57Z&se=2016-02-05T11%3A36%3A57Z&sp=rwd
这个文件在2个小时之内是可以进行不需要认证的访问的。
可以通过:
wget "https://portalvhds6mlqtd15wqmm7.blob.core.chinacloudapi.cn/hengweisoft/googlechrome.dmg?sv=2015-02-21&sr=b&sig=Ifn6JFOinaLQpYGKCKsYiUieQ58WdExxV2Z52Nx%2Fdjs%3D&st=2016-02-05T09%3A36%3A57Z&se=2016-02-05T11%3A36%3A57Z&sp=rwd"
直接获得这个文件。
使用PowerShell创建Azure Storage的SAS Token访问Azure Blob文件的更多相关文章
- 【Azure 存储服务】Java Azure Storage SDK V12使用Endpoint连接Blob Service遇见 The Azure Storage endpoint url is malformed
问题描述 使用Azure Storage Account的共享访问签名(Share Access Signature) 生成的终结点,连接时遇见 The Azure Storage endpoint ...
- Azure China (10) 使用Azure China SAS Token
<Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的Azure China 注意:本文介绍的是Azure China Storage Priva ...
- 【Azure 存储服务】代码版 Azure Storage Blob 生成 SAS (Shared Access Signature: 共享访问签名)
问题描述 在使用Azure存储服务,为了有效的保护Storage的Access Keys.可以使用另一种授权方式访问资源(Shared Access Signature: 共享访问签名), 它的好处可 ...
- [Azure Storage]使用Java上传文件到Storage并生成SAS签名
Azure官网提供了比较详细的文档,您可以参考:https://azure.microsoft.com/en-us/documentation/articles/storage-java-how-to ...
- 直传文件到Azure Storage的Blob服务中
(此文章同时发表在本人微信公众号“dotNET每日精华文章”,欢迎右边二维码来关注.) 题记:为了庆祝获得微信公众号赞赏功能,忙里抽闲分享一下最近工作的一点心得:如何直接从浏览器中上传文件到Azure ...
- Microsoft Azure Storage Exployer使用指南
概述 Microsoft Azure Storage Exployer 是微软官方推荐的一款管理Azure Storage 客户端工具,客户使用完全免费.支持Windows.Mac和Linux.用户使 ...
- Azure Queue Storage 基本用法 -- Azure Storage 之 Queue
Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure File Storage 基 ...
- Azure File Storage 基本用法 -- Azure Storage 之 File
Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Blob Storage 基 ...
- Azure Blob Storage 基本用法 -- Azure Storage 之 Blob
Azure Storage 是微软 Azure 云提供的云端存储解决方案,当前支持的存储类型有 Blob.Queue.File 和 Table. 笔者在<Azure Table storage ...
随机推荐
- polynomial time
https://en.wikipedia.org/wiki/Time_complexity#Polynomial_time An algorithm is said to be of polynomi ...
- full_case parallel_case学习心得
一般情况下,DC把case语句综合成选择器电路,但也可能把case语句综合成优先权译码电路.有时,优先权译码电路是不必要的,这是可以使用“// synopsys parallel_case”引导语句强 ...
- linux shell 中数组使用方法介绍
linux shell在编程方面比windows 批处理强大太多,不管是在循环.运算.已经数据类型方面都是不能比較的. 以下是个人在使用时候,对它在数组方面一些操作进行的总结. 1.数组定义 [che ...
- Linux expect介绍和用法
expect时用与提供自动交互的工具.比如如果想要用ssh登陆服务器,每次都输入密码你觉得麻烦,那你就可以使用expect来做自动交互,这样的话就不用每次都输入密码了. 先看例子: #!/usr/bi ...
- CodeForces - 580C Kefa and Park 【BFS】
题目链接 http://codeforces.com/problemset/problem/580/C 题意 根节点是 1 然后所有的叶子结点都是饭店 从根节点到叶子结点的路径上 如果存在 大于m 个 ...
- zabbix实现mysql数据库的监控(一)
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案.它能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问 ...
- Django之Form详解
Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 1.创建Form类.View函数处理 from ...
- POJ 2492 并查集 A Bug's Life
#include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> ...
- java深入探究07-jdbc上
1.连接数据库三种方式 //连接数据库的URL private String url = "jdbc:mysql://localhost:3306/day17"; // jdbc协 ...
- 算法(Algorithms)第4版 练习 2.1.25
代码实现: package com.qiusongde; import edu.princeton.cs.algs4.In; import edu.princeton.cs.algs4.StdOut; ...