BlobChangeFeedClient class
BlobChangeFeedClient。
請參閱https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
建構函式
Blob |
建立 BlobChangeFeedClient 的實例。 |
Blob |
建立 BlobChangeFeedClient 的實例。 |
方法
from |
從連接字串建立 BlobChangeFeedClient 的實例。 |
list |
傳回非同步反覆運算器,以列出指定帳戶中的所有變更摘要事件。 .byPage () 會傳回非同步反覆運算器,以列出頁面中的變更摘要事件。 使用語法的
使用
使用
搭配標記使用分頁的範例:
|
建構函式詳細資料
BlobChangeFeedClient(string, Pipeline)
建立 BlobChangeFeedClient 的實例。
new BlobChangeFeedClient(url: string, pipeline: Pipeline)
參數
- url
-
string
指向 Azure 儲存體 Blob 服務的用戶端字串,例如 「 https://myaccount.blob.core.windows.net" ;。 如果使用 AnonymousCredential,您可以附加 SAS,例如 「 https://myaccount.blob.core.windows.net?sasString" ;。
- pipeline
- Pipeline
呼叫 newPipeline () 以建立預設管線,或提供自訂管線。
BlobChangeFeedClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions, BlobChangeFeedClientOptions)
建立 BlobChangeFeedClient 的實例。
new BlobChangeFeedClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions, changeFeedClientOptions?: BlobChangeFeedClientOptions)
參數
- url
-
string
指向 Azure 儲存體 Blob 服務的用戶端字串,例如 「 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 管線的選項。
使用 DefaultAzureCredential 的範例: @azure/identity
const account = "<storage account name>";
const defaultAzureCredential = new DefaultAzureCredential();
const blobChangeFeedClient = new BlobChangeFeedClient(
`https://${account}.blob.core.windows.net`,
defaultAzureCredential
);
使用帳戶名稱/金鑰的範例:
const account = "<storage account name>"
const sharedKeyCredential = new StorageSharedKeyCredential(account, "<account key>");
const blobChangeFeedClient = new BlobChangeFeedClient(
`https://${account}.blob.core.windows.net`,
sharedKeyCredential
);
- changeFeedClientOptions
- BlobChangeFeedClientOptions
方法詳細資料
fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)
從連接字串建立 BlobChangeFeedClient 的實例。
static function fromConnectionString(connectionString: string, options?: StoragePipelineOptions, changeFeedClientOptions?: BlobChangeFeedClientOptions): BlobChangeFeedClient
參數
- connectionString
-
string
帳戶連接字串或 Azure 儲存體帳戶的 SAS 連接字串。
[ 注意 - 帳戶連接字串只能用於NODE.JS執行時間。 ] 帳戶連接字串範例 -DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net
SAS 連接字串範例 - BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString
- options
- StoragePipelineOptions
選擇性。 設定 HTTP 管線的選項。
- changeFeedClientOptions
- BlobChangeFeedClientOptions
傳回
listChanges(BlobChangeFeedListChangesOptions)
傳回非同步反覆運算器,以列出指定帳戶中的所有變更摘要事件。
.byPage () 會傳回非同步反覆運算器,以列出頁面中的變更摘要事件。
使用語法的 for await
範例:
let i = 1;
for await (const event of blobChangeFeedClient.listChanges()) {
console.log(`Event ${i++}, type: ${event.eventType}`);
}
使用 iter.next()
的範例:
let i = 1;
const iter = blobChangeFeedClient.listChanges();
let eventItem = await iter.next();
while (!eventItem.done) {
console.log(`Event ${i++}, type: ${eventItem.eventType}`);
eventItem = await iter.next();
}
使用 byPage()
的範例:
// passing optional maxPageSize in the page settings
let i = 1;
for await (const eventPage of blobChangeFeedClient.listChanges().byPage({ maxPageSize: 20 })) {
if (eventPage.events) {
for (const event of eventPage.events) {
console.log(`Event ${i++}, type: ${event.eventType}`);
}
}
}
搭配標記使用分頁的範例:
let i = 1;
let iterator = blobChangeFeedClient.listChanges().byPage({ maxPageSize: 2 });
let eventPage = (await iterator.next()).value;
if (eventPage.events) {
for (const container of eventPage.events) {
console.log(`Event ${i++}, type: ${event.eventType}`);
}
}
// Gets next marker
let marker = eventPage.continuationToken;
// Passing next marker as continuationToken
iterator = blobChangeFeedClient
.listChanges()
.byPage({ continuationToken: marker, maxPageSize: 10 });
eventPage = (await iterator.next()).value;
if (eventPage.events) {
for (const container of eventPage.events) {
console.log(`Event ${i++}, type: ${event.eventType}`);
}
}
function listChanges(options?: BlobChangeFeedListChangesOptions): PagedAsyncIterableIterator<BlobChangeFeedEvent, BlobChangeFeedEventPage, PageSettings>
參數
- options
- BlobChangeFeedListChangesOptions
列出變更摘要事件的選項。
傳回
支援分頁的 asyncIterableIterator。