Package version:
Creates an instance of BlobBatchClient.
A url pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".
Optionalcredential: anySuch as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
Optionaloptions: StoragePipelineOptionsOptions to configure the HTTP pipeline.
Creates an instance of BlobBatchClient.
A url pointing to Azure Storage blob service, such as "https://myaccount.blob.core.windows.net". You can append a SAS if using AnonymousCredential, such as "https://myaccount.blob.core.windows.net?sasString".
Call newPipeline() to create a default pipeline, or provide a customized pipeline.
Create multiple delete operations to mark the specified blobs or snapshots for deletion. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time. See delete operation details. The operations will be authenticated and authorized with specified credential. See blob batch authorization details.
The urls of the blob resources to delete.
Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
Optionaloptions: BlobDeleteOptionsCreate multiple delete operations to mark the specified blobs or snapshots for deletion. Note that in order to delete a blob, you must delete all of its snapshots. You can delete both at the same time. See delete operation details. The operation(subrequest) will be authenticated and authorized with specified credential. See blob batch authorization details.
The BlobClients for the blobs to delete.
Optionaloptions: BlobDeleteOptionsCreate multiple set tier operations to set the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. See set blob tier details. The operation(subrequest) will be authenticated and authorized with specified credential.See blob batch authorization details.
The urls of the blob resource to delete.
Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the @azure/identity package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
Optionaloptions: BlobSetTierOptionsCreate multiple set tier operations to set the tier on a blob. The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account (locally redundant storage only). A premium page blob's tier determines the allowed size, IOPS, and bandwidth of the blob. A block blob's tier determines Hot/Cool/Archive storage type. This operation does not update the blob's ETag. See set blob tier details. The operation(subrequest) will be authenticated and authorized with specified credential.See blob batch authorization details.
The BlobClients for the blobs which should have a new tier set.
Optionaloptions: BlobSetTierOptionsSubmit batch request which consists of multiple subrequests.
Get blobBatchClient and other details before running the snippets.
blobServiceClient.getBlobBatchClient() gives the blobBatchClient
Example usage:
import { DefaultAzureCredential } from "@azure/identity";
import { BlobServiceClient, BlobBatch } from "@azure/storage-blob";
const account = "<account>";
const credential = new DefaultAzureCredential();
const blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
credential,
);
const containerName = "<container name>";
const containerClient = blobServiceClient.getContainerClient(containerName);
const blobBatchClient = containerClient.getBlobBatchClient();
const batchRequest = new BlobBatch();
await batchRequest.deleteBlob("<blob-url-1>", credential);
await batchRequest.deleteBlob("<blob-url-2>", credential, {
deleteSnapshots: "include",
});
const batchResp = await blobBatchClient.submitBatch(batchRequest);
console.log(batchResp.subResponsesSucceededCount);
Example using a lease:
import { DefaultAzureCredential } from "@azure/identity";
import { BlobServiceClient, BlobBatch } from "@azure/storage-blob";
const account = "<account>";
const credential = new DefaultAzureCredential();
const blobServiceClient = new BlobServiceClient(
`https://${account}.blob.core.windows.net`,
credential,
);
const containerName = "<container name>";
const containerClient = blobServiceClient.getContainerClient(containerName);
const blobBatchClient = containerClient.getBlobBatchClient();
const blobClient = containerClient.getBlobClient("<blob name>");
const batchRequest = new BlobBatch();
await batchRequest.setBlobAccessTier(blobClient, "Cool");
await batchRequest.setBlobAccessTier(blobClient, "Cool", {
conditions: { leaseId: "<lease-id>" },
});
const batchResp = await blobBatchClient.submitBatch(batchRequest);
console.log(batchResp.subResponsesSucceededCount);
A set of Delete or SetTier operations.
A BlobBatchClient allows you to make batched requests to the Azure Storage Blob service.
See
https://learn.microsoft.com/rest/api/storageservices/blob-batch