<PackageReference Include="Azure.Storage.Blobs" Version="12.25.0" />

BlobSasBuilder

public class BlobSasBuilder
BlobSasBuilder is used to generate a Shared Access Signature (SAS) for an Azure Storage container or blob. For more information, see Create a service SAS.
public string BlobContainerName { get; set; }

The name of the blob container being made accessible.

public string BlobName { get; set; }

The name of the blob being made accessible, or Empty for a container SAS.

public string BlobVersionId { get; set; }

The name of the blob version being made accessible, or Empty for a blob SAS.

public string CacheControl { get; set; }

Override the value returned for Cache-Control response header.

public string ContentDisposition { get; set; }

Override the value returned for Content-Disposition response header.

public string ContentEncoding { get; set; }

Override the value returned for Content-Encoding response header.

public string ContentLanguage { get; set; }

Override the value returned for Content-Language response header.

public string ContentType { get; set; }

Override the value returned for Content-Type response header.

public string CorrelationId { get; set; }

Optional. Beginning in version 2020-02-10, this value will be used for to correlate the storage audit logs with the audit logs used by the principal generating and distributing SAS. This is only used for User Delegation SAS.

public string EncryptionScope { get; set; }

Optional. Encryption scope to use when sending requests authorized with this SAS URI.

public DateTimeOffset ExpiresOn { get; set; }

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 string Identifier { get; set; }

An optional unique value up to 64 characters in length that correlates to an access policy specified for the container.

public SasIPRange IPRange { get; set; }

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 string Permissions { get; }

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 BlobSasPermissions, BlobContainerSasPermissions, SnapshotSasPermissions, or BlobAccountSasPermissions can be used to create the permissions string.

public string PreauthorizedAgentObjectId { get; set; }

Optional. Beginning in version 2020-02-10, this value will be used for the AAD Object ID of a user authorized by the owner of the User Delegation Key to perform the action granted by the SAS. The Azure Storage service will ensure that the owner of the user delegation key has the required permissions before granting access. No additional permission check for the user specified in this value will be performed. This is only used with generating User Delegation SAS.

public SasProtocol Protocol { get; set; }

The optional signed protocol field specifies the protocol permitted for a request made with the SAS. Possible values are HttpsAndHttp, Https, and None.

public string Resource { get; set; }

Specifies which resources are accessible via the shared access signature. Specify "b" if the shared resource is a blob. This grants access to the content and metadata of the blob. Specify "c" if the shared resource is a blob container. This grants access to the content and metadata of any blob in the container, and to the list of blobs in the container. Beginning in version 2018-11-09, specify "bs" if the shared resource is a blob snapshot. This grants access to the content and metadata of the specific snapshot, but not the corresponding root blob. Beginning in version 2019-12-12, specify "bv" if the shared resource is a blob version. This grants access to the content and metadata of the specific version, but not the corresponding root blob.

public string Snapshot { get; set; }

The name of the snapshot being made accessible, or Empty for a blob SAS.

public DateTimeOffset StartsOn { get; set; }

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 string Version { get; set; }

The storage service version to use to authenticate requests made with this shared access signature, and the service version to use when handling requests made with this shared access signature.

public BlobSasBuilder()

Initializes a new instance of the BlobSasBuilder class.

public BlobSasBuilder(BlobSasPermissions permissions, DateTimeOffset expiresOn)

Initializes a new instance of the BlobSasBuilder class to create a Blob Service Sas.

Initializes a new instance of the BlobSasBuilder class to create a Blob Container Service Sas.

public void SetPermissions(BlobSasPermissions permissions)

Sets the permissions for a blob SAS.

public void SetPermissions(BlobAccountSasPermissions permissions)

Sets the permissions for a blob account level SAS.

Sets the permissions for a blob container SAS.

public void SetPermissions(SnapshotSasPermissions permissions)

Sets the permissions for a Snapshot SAS.

public void SetPermissions(BlobVersionSasPermissions permissions)

Sets the permissions for a Version SAS.

public void SetPermissions(string rawPermissions, bool normalize = false)

Sets the permissions for the SAS using a raw permissions string.

public void SetPermissions(string rawPermissions)

Sets the permissions for the SAS using a raw permissions string.

Use an account's StorageSharedKeyCredential to sign this shared access signature values to produce the proper SAS query parameters for authenticating requests.

public BlobSasQueryParameters ToSasQueryParameters(StorageSharedKeyCredential sharedKeyCredential, out string stringToSign)

Use an account's StorageSharedKeyCredential to sign this shared access signature values to produce the proper SAS query parameters for authenticating requests.

public BlobSasQueryParameters ToSasQueryParameters(UserDelegationKey userDelegationKey, string accountName)

Use an account's UserDelegationKey to sign this shared access signature values to produce the proper SAS query parameters for authenticating requests.

public BlobSasQueryParameters ToSasQueryParameters(UserDelegationKey userDelegationKey, string accountName, out string stringToSign)

Use an account's UserDelegationKey to sign this shared access signature values to produce the proper SAS query parameters for authenticating requests.