你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzStorageFileSASToken
为存储文件生成共享访问签名令牌。
语法
New-AzStorageFileSASToken
[-ShareName] <String>
[-Path] <String>
[-Permission <String>]
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
New-AzStorageFileSASToken
[-ShareName] <String>
[-Path] <String>
-Policy <String>
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
New-AzStorageFileSASToken
-ShareFileClient <ShareFileClient>
[-Permission <String>]
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
New-AzStorageFileSASToken
-ShareFileClient <ShareFileClient>
-Policy <String>
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
New-AzStorageFileSASToken cmdlet 为 Azure 存储文件生成共享访问签名令牌。
示例
示例 1:生成具有完整文件权限的共享访问签名令牌
New-AzStorageFileSASToken -ShareName "ContosoShare" -Path "FilePath" -Permission "rwd"
此命令生成对名为 FilePath 的文件具有完全权限的共享访问签名令牌。
示例 2:生成具有时间限制的共享访问签名令牌
$StartTime = Get-Date
$EndTime = $StartTime.AddHours(2.0)
New-AzStorageFileSASToken -ShareName "ContosoShare" -Path "FilePath" -Permission "rwd" -StartTime $StartTime -ExpiryTime $EndTime
第一个命令使用 Get-Date cmdlet 创建 DateTime 对象。 该命令将当前时间存储在$StartTime变量中。 第二个命令将两小时添加到$StartTime中的对象,然后将结果存储在$EndTime变量中。 此对象是将来两个小时的时间。 第三个命令生成具有指定权限的共享访问签名令牌。 此令牌在当前时间生效。 令牌一直有效,直到存储在$EndTime中的时间。
参数
-Context
指定 Azure 存储上下文。 若要获取上下文,请使用 New-AzStorageContext cmdlet。
类型: | IStorageContext |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ExpiryTime
指定共享访问签名失效的时间。
类型: | Nullable<T>[DateTime] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-FullUri
指示此 cmdlet 返回完整的 Blob URI 和共享访问签名令牌。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-IPAddressOrRange
指定要从中接受请求的 IP 地址或 IP 地址范围,例如 168.1.5.65 或 168.1.5.60-168.1.5.70。 范围是非独占的。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Path
指定文件相对于存储共享的路径。
类型: | String |
Position: | 1 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Permission
指定存储文件的权限。
请务必注意,这是一个字符串,如 rwd
(对于读取、写入和删除)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Policy
指定文件的存储访问策略。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Protocol
指定请求允许的协议。 此参数的可接受值为:
- HttpsOnly
- HttpsOrHttp 默认值为 HttpsOrHttp。
类型: | String |
接受的值: | HttpsOnly, HttpsOrHttp |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ShareFileClient
要表示要对其获取 SAS 令牌的文件的 ShareFileClient 实例。
类型: | ShareFileClient |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-ShareName
指定存储共享的名称。
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-StartTime
指定共享访问签名生效的时间。
类型: | Nullable<T>[DateTime] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |