New-AzStorageFileSASToken
Generates a shared access signature token for a Storage file.
Syntax
NameSasPermission
New-AzStorageFileSASToken
[-ShareName] <String>
[-Path] <String>
[-Permission <String>]
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
NameSasPolicy
New-AzStorageFileSASToken
[-ShareName] <String>
[-Path] <String>
-Policy <String>
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
FileSasPermission
New-AzStorageFileSASToken
-ShareFileClient <ShareFileClient>
[-Permission <String>]
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
FileSasPolicy
New-AzStorageFileSASToken
-ShareFileClient <ShareFileClient>
-Policy <String>
[-Protocol <String>]
[-IPAddressOrRange <String>]
[-StartTime <DateTime>]
[-ExpiryTime <DateTime>]
[-FullUri]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The New-AzStorageFileSASToken cmdlet generates a shared access signature token for an Azure Storage file.
Examples
Example 1: Generate a shared access signature token that has full file permissions
New-AzStorageFileSASToken -ShareName "ContosoShare" -Path "FilePath" -Permission "rwd"
This command generates a shared access signature token that has full permissions for the file that is named FilePath.
Example 2: Generate a shared access signature token that has a time limit
$StartTime = Get-Date
$EndTime = $StartTime.AddHours(2.0)
New-AzStorageFileSASToken -ShareName "ContosoShare" -Path "FilePath" -Permission "rwd" -StartTime $StartTime -ExpiryTime $EndTime
The first command creates a DateTime object by using the Get-Date cmdlet.
The command stores the current time in the $StartTime variable.
The second command adds two hours to the object in $StartTime, and then stores the result in the $EndTime variable.
This object is a time two hours in the future.
The third command generates a shared access signature token that has the specified permissions.
This token becomes valid at the current time.
The token remains valid until time stored in $EndTime.
Parameters
-Context
Specifies an Azure Storage context.
To obtain a context, use the New-AzStorageContext cmdlet.
Parameter properties
Type: IStorageContext
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ExpiryTime
Specifies the time at which the shared access signature becomes invalid.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-FullUri
Indicates that this cmdlet return the full blob URI and the shared access signature token.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-IPAddressOrRange
Specifies the IP address or range of IP addresses from which to accept requests, such as 168.1.5.65 or 168.1.5.60-168.1.5.70.
The range is inclusive.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Path
Specifies the path of the file relative to a Storage share.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
NameSasPermission
Position: 1
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
NameSasPolicy
Position: 1
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
-Permission
Specifies the permissions for a Storage file.
It is important to note that this is a string, like rwd (for Read, Write and Delete).
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
NameSasPermission
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
FileSasPermission
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Policy
Specifies the stored access policy for a file.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
NameSasPolicy
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
FileSasPolicy
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Protocol
Specifies the protocol permitted for a request.
The acceptable values for this parameter are:
HttpsOnly
HttpsOrHttp
The default value is HttpsOrHttp.
Parameter properties
Type: String
Default value: None
Accepted values: HttpsOnly, HttpsOrHttp
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ShareFileClient
ShareFileClient instance to represent the file to get SAS token against.
Parameter properties
Type: ShareFileClient
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
FileSasPermission
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
FileSasPolicy
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
-ShareName
Specifies the name of the Storage share.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
NameSasPermission
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
NameSasPolicy
Position: 0
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: True
Value from remaining arguments: False
-StartTime
Specifies the time at which the shared access signature becomes valid.
Parameter properties
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs