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。