< Back

New-AzureStorageFileSASToken

Tue Jan 29, 2019 9:27 pm

NAME New-AzureStorageFileSASToken



SYNOPSIS

Generates a shared access signature token for a Storage file.





SYNTAX

New-AzureStorageFileSASToken [-ShareName] <String> [-Path] <String> [-Context <IStorageContext>] [-ExpiryTime <DateTime>] [-FullUri]

[-IPAddressOrRange <String>] [-Permission <String>] [-Protocol {HttpsOnly | HttpsOrHttp}] [-StartTime <DateTime>] [<CommonParameters>]



New-AzureStorageFileSASToken [-ShareName] <String> [-Path] <String> [-Context <IStorageContext>] [-ExpiryTime <DateTime>] [-FullUri]

[-IPAddressOrRange <String>] -Policy <String> [-Protocol {HttpsOnly | HttpsOrHttp}] [-StartTime <DateTime>] [<CommonParameters>]



New-AzureStorageFileSASToken [-ExpiryTime <DateTime>] -File <CloudFile> [-FullUri] [-IPAddressOrRange <String>] [-Permission <String>] [-Protocol

{HttpsOnly | HttpsOrHttp}] [-StartTime <DateTime>] [<CommonParameters>]



New-AzureStorageFileSASToken [-ExpiryTime <DateTime>] -File <CloudFile> [-FullUri] [-IPAddressOrRange <String>] -Policy <String> [-Protocol

{HttpsOnly | HttpsOrHttp}] [-StartTime <DateTime>] [<CommonParameters>]





DESCRIPTION

The New-AzureStorageFileSASToken cmdlet generates a shared access signature token for an Azure Storage file.





PARAMETERS

-Context <IStorageContext>

Specifies an Azure Storage context. To obtain a context, use the New-AzureStorageContext cmdlet.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-ExpiryTime <DateTime>

Specifies the time at which the shared access signature becomes invalid.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-File <CloudFile>

Specifies a CloudFile object. You can create a cloud file or obtain one by using the Get-AzureStorageFile cmdlet.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-FullUri [<SwitchParameter>]

Indicates that this cmdlet return the full blob URI and the shared access signature token.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-IPAddressOrRange <String>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Path <String>

Specifies the path of the file relative to a Storage share.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-Permission <String>

Specifies the permissions for a Storage file.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Policy <String>

Specifies the stored access policy for a file.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Protocol <SharedAccessProtocol>

Specifies the protocol permitted for a request. The acceptable values for this parameter are: * HttpsOnly



* HttpsOrHttp





The default value is HttpsOrHttp.





Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ShareName <String>

Specifies the name of the Storage share.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-StartTime <DateTime>

Specifies the time at which the shared access signature becomes valid.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

IStorageContext

Parameter 'Context' accepts value of type 'IStorageContext' from the pipeline



CloudFile

Parameter 'File' accepts value of type 'CloudFile' from the pipeline



String

Parameter 'Path' accepts value of type 'String' from the pipeline



String

Parameter 'ShareName' accepts value of type 'String' from the pipeline





OUTPUTS

System.String







NOTES









Example 1: Generate a shared access signature token that has full file permissions



PS C:\\> New-AzureStorageFileSASToken -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



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



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.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... lesastoken

New-AzureStorageContext

New-AzureStorageShareSASToken