Class ShareSasBuilder
ShareSasBuilder is used to generate a Shared Access Signature (SAS) for an Azure Storage share, directory, or file.
For more information, see Creating a Service SAS.
public class ShareSasBuilder
- Inheritance
-
ShareSasBuilder
- Inherited Members
Constructors
ShareSasBuilder(ShareFileSasPermissions, DateTimeOffset)
Initializes a new instance of the ShareSasBuilder class to create a Azure File Sas.
public ShareSasBuilder(ShareFileSasPermissions permissions, DateTimeOffset expiresOn)
Parameters
permissions
ShareFileSasPermissionsThe permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. This field must be omitted if it has been specified in an associated stored access policy.
expiresOn
DateTimeOffsetThe time at which the shared access signature becomes invalid. This field must be omitted if it has been specified in an associated stored access policy.
ShareSasBuilder(ShareSasPermissions, DateTimeOffset)
Initializes a new instance of the ShareSasBuilder class to create a File Share Sas.
public ShareSasBuilder(ShareSasPermissions permissions, DateTimeOffset expiresOn)
Parameters
permissions
ShareSasPermissionsThe permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. This field must be omitted if it has been specified in an associated stored access policy.
expiresOn
DateTimeOffsetThe time at which the shared access signature becomes invalid. This field must be omitted if it has been specified in an associated stored access policy.
Properties
CacheControl
Override the value returned for Cache-Control response header.
public string CacheControl { get; set; }
Property Value
ContentDisposition
Override the value returned for Content-Disposition response header.
public string ContentDisposition { get; set; }
Property Value
ContentEncoding
Override the value returned for Cache-Encoding response header.
public string ContentEncoding { get; set; }
Property Value
ContentLanguage
Override the value returned for Cache-Language response header.
public string ContentLanguage { get; set; }
Property Value
ContentType
Override the value returned for Cache-Type response header.
public string ContentType { get; set; }
Property Value
ExpiresOn
The time at which the shared access signature becomes invalid. This field must be omitted if it has been specified in an associated stored access policy.
public DateTimeOffset ExpiresOn { get; set; }
Property Value
FilePath
The path of the file or directory being made accessible, or Empty for a share SAS.
public string FilePath { get; set; }
Property Value
IPRange
Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. When specifying a range of IP addresses, note that the range is inclusive.
public SasIPRange IPRange { get; set; }
Property Value
- SasIPRange
Identifier
An optional unique value up to 64 characters in length that correlates to an access policy specified for the share.
public string Identifier { get; set; }
Property Value
Permissions
The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. This field must be omitted if it has been specified in an associated stored access policy. The ShareFileSasPermissions, ShareSasPermissions, or ShareAccountSasPermissions can be used to create the permissions string.
public string Permissions { get; }
Property Value
Protocol
The optional signed protocol field specifies the protocol permitted for a request made with the SAS. Possible values are Azure.Storage.Sas.SasProtocol.HttpsAndHttp, Azure.Storage.Sas.SasProtocol.Https, and Azure.Storage.Sas.SasProtocol.None.
public SasProtocol Protocol { get; set; }
Property Value
- SasProtocol
Resource
Specifies which resources are accessible via the shared access signature.
Specify "f" if the shared resource is a file. This grants access to the content and metadata of the file.
Specify "s" if the shared resource is a share. This grants access to the content and metadata of any file in the share, and to the list of directories and files in the share.
public string Resource { get; set; }
Property Value
ShareName
The name of the share being made accessible.
public string ShareName { get; set; }
Property Value
StartsOn
Optionally specify the time at which the shared access signature becomes valid. If omitted when DateTimeOffset.MinValue is used, start time for this call is assumed to be the time when the storage service receives the request.
public DateTimeOffset StartsOn { get; set; }
Property Value
Methods
SetPermissions(ShareAccountSasPermissions)
Sets the permissions for a file account level SAS.
public void SetPermissions(ShareAccountSasPermissions permissions)
Parameters
permissions
ShareAccountSasPermissionsShareAccountSasPermissions containing the allowed permissions.
SetPermissions(ShareFileSasPermissions)
Sets the permissions for a file SAS.
public void SetPermissions(ShareFileSasPermissions permissions)
Parameters
permissions
ShareFileSasPermissionsShareFileSasPermissions containing the allowed permissions.
SetPermissions(ShareSasPermissions)
Sets the permissions for a share SAS.
public void SetPermissions(ShareSasPermissions permissions)
Parameters
permissions
ShareSasPermissionsShareSasPermissions containing the allowed permissions.
SetPermissions(string)
Sets the permissions for the SAS using a raw permissions string.
public void SetPermissions(string rawPermissions)
Parameters
rawPermissions
stringRaw permissions string for the SAS.
SetPermissions(string, bool)
Sets the permissions for the SAS using a raw permissions string.
public void SetPermissions(string rawPermissions, bool normalize = false)
Parameters
rawPermissions
stringRaw permissions string for the SAS.
normalize
boolIf the permissions should be validated and correctly ordered.
ToSasQueryParameters(StorageSharedKeyCredential)
Use an account's Azure.Storage.StorageSharedKeyCredential to sign this shared access signature values to produce the proper SAS query parameters for authenticating requests.
public SasQueryParameters ToSasQueryParameters(StorageSharedKeyCredential sharedKeyCredential)
Parameters
sharedKeyCredential
StorageSharedKeyCredentialThe storage account's Azure.Storage.StorageSharedKeyCredential.
Returns
- SasQueryParameters
The Azure.Storage.Sas.SasQueryParameters used for authenticating requests.