Package version:
ONLY AVAILABLE IN NODE.JS RUNTIME.
Creates an instance of SASQueryParameters. WARNING: identifier will be ignored when generating user delegation SAS, permissions and expiresOn are required.
Example usage:
import {
BlobServiceClient,
generateBlobSASQueryParameters,
ContainerSASPermissions,
SASProtocol,
} from "@azure/storage-blob";
import { DefaultAzureCredential } from "@azure/identity";
const account = "<account>";
const blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
new DefaultAzureCredential(),
);
const containerName = "<container name>";
const accountName = "<account name>";
const startsOn = new Date();
const expiresOn = new Date(new Date().valueOf() + 86400 * 1000);
// Generate user delegation SAS for a container
const userDelegationKey = await blobServiceClient.getUserDelegationKey(startsOn, expiresOn);
const containerSAS = generateBlobSASQueryParameters(
{
containerName, // Required
permissions: ContainerSASPermissions.parse("racwdl"), // Required
startsOn, // Optional. Date type
expiresOn, // Required. Date type
ipRange: { start: "0.0.0.0", end: "255.255.255.255" }, // Optional
protocol: SASProtocol.HttpsAndHttp, // Optional
version: "2018-11-09", // Must greater than or equal to 2018-11-09 to generate user delegation SAS
},
userDelegationKey, // UserDelegationKey
accountName,
).toString();
Return value of blobServiceClient.getUserDelegationKey()
ONLY AVAILABLE IN NODE.JS RUNTIME.
Creates an instance of SASQueryParameters.
Only accepts required settings needed to create a SAS. For optional settings please set corresponding properties directly, such as permissions, startsOn and identifier.
WARNING: When identifier is not provided, permissions and expiresOn are required. You MUST assign value to identifier or expiresOn & permissions manually if you initial with this constructor.
Fill in the required details before running the following snippets.
Example usage:
Example using an identifier:
Example using a blob name: