你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzureStorageFileSASToken
为存储文件生成共享访问签名令牌。
警告
截至 2024 年 2 月 29 日,AzureRM PowerShell 模块已正式弃用。 为了确保持续获得支持和更新,建议用户从 AzureRM 迁移到 Az PowerShell 模块。
尽管 AzureRM 模块仍可能正常运行,但它不再维护或受支持,但会根据用户的自由裁量权和风险继续使用任何继续使用模块。 有关过渡到 Az 模块的指导,请参阅我们的迁移资源。
语法
New-AzureStorageFileSASToken
[-ShareName] <String>
[-Path] <String>
[-Permission <String>]
[-Protocol <SharedAccessProtocol>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
New-AzureStorageFileSASToken
[-ShareName] <String>
[-Path] <String>
-Policy <String>
[-Protocol <SharedAccessProtocol>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
New-AzureStorageFileSASToken
-File <CloudFile>
[-Permission <String>]
[-Protocol <SharedAccessProtocol>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
New-AzureStorageFileSASToken
-File <CloudFile>
-Policy <String>
[-Protocol <SharedAccessProtocol>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
New-Azure存储FileSASToken cmdlet 为Azure 存储文件生成共享访问签名令牌。
示例
示例 1:生成具有完整文件权限的共享访问签名令牌
PS C:\> New-AzureStorageFileSASToken -ShareName "ContosoShare" -Path "FilePath" -Permission "rwd"
此命令生成对名为 FilePath 的文件具有完全权限的共享访问签名令牌。
示例 2:生成具有时间限制的共享访问签名令牌
PS C:\> $StartTime = Get-Date
PS C:\> $EndTime = $StartTime.AddHours(2.0)
PS C:\> New-AzureStorageFileSASToken -ShareName "ContosoShare" -Path "FilePath" -Permission "rwd" -StartTime $StartTime -ExpiryTime $EndTime
第一个 命令使用 Get-Date cmdlet 创建 DateTime 对象。 该命令将当前时间存储在$StartTime变量中。 第二个命令将两小时添加到$StartTime中的对象,然后将结果存储在$EndTime变量中。 此对象是将来两个小时的时间。 第三个命令生成具有指定权限的共享访问签名令牌。 此令牌在当前时间生效。 令牌一直有效,直到存储在$EndTime中的时间。
参数
-Context
指定Azure 存储上下文。 若要获取上下文,请使用 New-Azure存储Context 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 |
-File
指定 CloudFile 对象。 可以使用 Get-Azure存储File cmdlet 创建云文件或获取一个。
类型: | CloudFile |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | 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。
类型: | Nullable<T>[SharedAccessProtocol] |
接受的值: | HttpsOnly, HttpsOrHttp |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ShareName
指定存储共享的名称。
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-StartTime
指定共享访问签名生效的时间。
类型: | Nullable<T>[DateTime] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
参数:上下文(ByValue)