共用方式為


BlobBatchClient class

BlobBatchClient 可讓您對 Azure 記憶體 Blob 服務提出批次要求。

請參閱 https://learn.microsoft.com/rest/api/storageservices/blob-batch

建構函式

BlobBatchClient(string, PipelineLike)

建立 BlobBatchClient 的實例。

BlobBatchClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)

建立 BlobBatchClient 的實例。

方法

createBatch()

建立 BlobBatch。 BlobBatch 代表 Blob 上的一組匯總作業。

deleteBlobs(BlobClient[], BlobDeleteOptions)

建立多個刪除作業,以標記要刪除的指定 Blob 或快照集。 請注意,若要刪除 Blob,您必須刪除其所有快照集。 您可以同時刪除兩者。 請參閱 刪除工作詳細資料。 作業(subrequest)將會以指定的認證進行驗證和授權。 請參閱 blob 批次授權詳細數據

deleteBlobs(string[], StorageSharedKeyCredential | AnonymousCredential | TokenCredential, BlobDeleteOptions)

建立多個刪除作業,以標記要刪除的指定 Blob 或快照集。 請注意,若要刪除 Blob,您必須刪除其所有快照集。 您可以同時刪除兩者。 請參閱 刪除工作詳細資料。 作業將會透過指定的認證進行驗證和授權。 請參閱 blob 批次授權詳細數據

setBlobsAccessTier(BlobClient[], AccessTier, BlobSetTierOptions)

建立多個集合層作業,以在 Blob 上設定該層。 此作業允許在進階記憶體帳戶中的分頁 Blob 和 Blob 記憶體帳戶中的區塊 Blob 上(僅限本地備援記憶體)。 進階分頁 Blob 的層會決定 Blob 的允許大小、IOPS 和頻寬。 區塊 Blob 的層會決定經常性存取/非經常性存取/封存記憶體類型。 此作業不會更新 Blob 的 ETag。 請參閱 設定 Blob 層詳細數據。 作業(subrequest)將會以指定的認證進行驗證和授權。請參閱 blob 批次授權詳細數據

setBlobsAccessTier(string[], StorageSharedKeyCredential | AnonymousCredential | TokenCredential, AccessTier, BlobSetTierOptions)

建立多個集合層作業,以在 Blob 上設定該層。 此作業允許在進階記憶體帳戶中的分頁 Blob 和 Blob 記憶體帳戶中的區塊 Blob 上(僅限本地備援記憶體)。 進階分頁 Blob 的層會決定 Blob 的允許大小、IOPS 和頻寬。 區塊 Blob 的層會決定經常性存取/非經常性存取/封存記憶體類型。 此作業不會更新 Blob 的 ETag。 請參閱 設定 Blob 層詳細數據。 作業(subrequest)將會以指定的認證進行驗證和授權。請參閱 blob 批次授權詳細數據

submitBatch(BlobBatch, BlobBatchSubmitBatchOptionalParams)

提交由多個子要求組成的批次要求。

在執行代碼段之前,先取得 blobBatchClient 和其他詳細數據。 blobServiceClient.getBlobBatchClient() 提供 blobBatchClient

範例用法:

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);

使用租用的範例:

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);

請參閱 https://learn.microsoft.com/rest/api/storageservices/blob-batch

建構函式詳細資料

BlobBatchClient(string, PipelineLike)

建立 BlobBatchClient 的實例。

new BlobBatchClient(url: string, pipeline: PipelineLike)

參數

url

string

指向 Azure 記憶體 Blob 服務的 URL,例如 「https://myaccount.blob.core.windows.net"。 如果使用 AnonymousCredential,則可以附加 SAS,例如 “https://myaccount.blob.core.windows.net?sasString"。

pipeline
PipelineLike

呼叫 newPipeline() 以建立預設管線,或提供自定義管線。

BlobBatchClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions)

建立 BlobBatchClient 的實例。

new BlobBatchClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)

參數

url

string

指向 Azure 記憶體 Blob 服務的 URL,例如 「https://myaccount.blob.core.windows.net"。 如果使用 AnonymousCredential,則可以附加 SAS,例如 “https://myaccount.blob.core.windows.net?sasString"。

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

例如 AnonymousCredential、StorageSharedKeyCredential 或任何來自 @azure/identity 套件的認證,以驗證對服務的要求。 您也可以提供實作 TokenCredential 介面的物件。 如果未指定,則會使用 AnonymousCredential。

options
StoragePipelineOptions

設定 HTTP 管線的選項。

方法詳細資料

createBatch()

建立 BlobBatch。 BlobBatch 代表 Blob 上的一組匯總作業。

function createBatch(): BlobBatch

傳回

deleteBlobs(BlobClient[], BlobDeleteOptions)

建立多個刪除作業,以標記要刪除的指定 Blob 或快照集。 請注意,若要刪除 Blob,您必須刪除其所有快照集。 您可以同時刪除兩者。 請參閱 刪除工作詳細資料。 作業(subrequest)將會以指定的認證進行驗證和授權。 請參閱 blob 批次授權詳細數據

function deleteBlobs(blobClients: BlobClient[], options?: BlobDeleteOptions): Promise<BlobBatchSubmitBatchResponse>

參數

blobClients

BlobClient[]

要刪除之 Blob 的 BlobClients。

傳回

deleteBlobs(string[], StorageSharedKeyCredential | AnonymousCredential | TokenCredential, BlobDeleteOptions)

建立多個刪除作業,以標記要刪除的指定 Blob 或快照集。 請注意,若要刪除 Blob,您必須刪除其所有快照集。 您可以同時刪除兩者。 請參閱 刪除工作詳細資料。 作業將會透過指定的認證進行驗證和授權。 請參閱 blob 批次授權詳細數據

function deleteBlobs(urls: string[], credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: BlobDeleteOptions): Promise<BlobBatchSubmitBatchResponse>

參數

urls

string[]

要刪除之 Blob 資源的 URL。

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

例如 AnonymousCredential、StorageSharedKeyCredential 或任何來自 @azure/identity 套件的認證,以驗證對服務的要求。 您也可以提供實作 TokenCredential 介面的物件。 如果未指定,則會使用 AnonymousCredential。

傳回

setBlobsAccessTier(BlobClient[], AccessTier, BlobSetTierOptions)

建立多個集合層作業,以在 Blob 上設定該層。 此作業允許在進階記憶體帳戶中的分頁 Blob 和 Blob 記憶體帳戶中的區塊 Blob 上(僅限本地備援記憶體)。 進階分頁 Blob 的層會決定 Blob 的允許大小、IOPS 和頻寬。 區塊 Blob 的層會決定經常性存取/非經常性存取/封存記憶體類型。 此作業不會更新 Blob 的 ETag。 請參閱 設定 Blob 層詳細數據。 作業(subrequest)將會以指定的認證進行驗證和授權。請參閱 blob 批次授權詳細數據

function setBlobsAccessTier(blobClients: BlobClient[], tier: AccessTier, options?: BlobSetTierOptions): Promise<BlobBatchSubmitBatchResponse>

參數

blobClients

BlobClient[]

BlobClients,其 Blob 應該已設定新的層。

tier
AccessTier

傳回

setBlobsAccessTier(string[], StorageSharedKeyCredential | AnonymousCredential | TokenCredential, AccessTier, BlobSetTierOptions)

建立多個集合層作業,以在 Blob 上設定該層。 此作業允許在進階記憶體帳戶中的分頁 Blob 和 Blob 記憶體帳戶中的區塊 Blob 上(僅限本地備援記憶體)。 進階分頁 Blob 的層會決定 Blob 的允許大小、IOPS 和頻寬。 區塊 Blob 的層會決定經常性存取/非經常性存取/封存記憶體類型。 此作業不會更新 Blob 的 ETag。 請參閱 設定 Blob 層詳細數據。 作業(subrequest)將會以指定的認證進行驗證和授權。請參閱 blob 批次授權詳細數據

function setBlobsAccessTier(urls: string[], credential: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, tier: AccessTier, options?: BlobSetTierOptions): Promise<BlobBatchSubmitBatchResponse>

參數

urls

string[]

要刪除之 Blob 資源的 URL。

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

例如 AnonymousCredential、StorageSharedKeyCredential 或任何來自 @azure/identity 套件的認證,以驗證對服務的要求。 您也可以提供實作 TokenCredential 介面的物件。 如果未指定,則會使用 AnonymousCredential。

tier
AccessTier

傳回

submitBatch(BlobBatch, BlobBatchSubmitBatchOptionalParams)

提交由多個子要求組成的批次要求。

在執行代碼段之前,先取得 blobBatchClient 和其他詳細數據。 blobServiceClient.getBlobBatchClient() 提供 blobBatchClient

範例用法:

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);

使用租用的範例:

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);

請參閱 https://learn.microsoft.com/rest/api/storageservices/blob-batch

function submitBatch(batchRequest: BlobBatch, options?: BlobBatchSubmitBatchOptionalParams): Promise<BlobBatchSubmitBatchResponse>

參數

batchRequest
BlobBatch

一組 Delete 或 SetTier 作業。

傳回