Bagikan melalui


BlobChangeFeedClient class

Konstruktor

BlobChangeFeedClient(string, Pipeline)

Membuat instans BlobChangeFeedClient.

BlobChangeFeedClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions, BlobChangeFeedClientOptions)

Membuat instans BlobChangeFeedClient.

Metode

fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)

Membuat instans BlobChangeFeedClient dari string koneksi.

listChanges(BlobChangeFeedListChangesOptions)

Mengembalikan iterator yang dapat diulang asinkron untuk mencantumkan semua peristiwa umpan perubahan di akun yang ditentukan.

.byPage() mengembalikan iterator yang dapat diulang asinkron untuk mencantumkan peristiwa umpan perubahan di halaman.

Contoh menggunakan sintaks for await:

let i = 1;
for await (const event of blobChangeFeedClient.listChanges()) {
  console.log(`Event ${i++}, type: ${event.eventType}`);
}

Contoh menggunakan 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();
}

Contoh menggunakan 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}`);
    }
  }
}

Contoh menggunakan halaman dengan penanda:

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

Detail Konstruktor

BlobChangeFeedClient(string, Pipeline)

Membuat instans BlobChangeFeedClient.

new BlobChangeFeedClient(url: string, pipeline: Pipeline)

Parameter

url

string

String Klien yang menunjuk ke layanan blob Azure Storage, seperti "https://myaccount.blob.core.windows.net". Anda dapat menambahkan SAS jika menggunakan AnonymousCredential, seperti "https://myaccount.blob.core.windows.net?sasString".

pipeline
Pipeline

Panggil newPipeline() untuk membuat alur default, atau sediakan alur yang disesuaikan.

BlobChangeFeedClient(string, StorageSharedKeyCredential | AnonymousCredential | TokenCredential, StoragePipelineOptions, BlobChangeFeedClientOptions)

Membuat instans BlobChangeFeedClient.

new BlobChangeFeedClient(url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions, changeFeedClientOptions?: BlobChangeFeedClientOptions)

Parameter

url

string

String Klien yang menunjuk ke layanan blob Azure Storage, seperti "https://myaccount.blob.core.windows.net". Anda dapat menambahkan SAS jika menggunakan AnonymousCredential, seperti "https://myaccount.blob.core.windows.net?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Seperti AnonymousCredential, StorageSharedKeyCredential atau kredensial apa pun dari paket @azure/identity untuk mengautentikasi permintaan ke layanan. Anda juga dapat menyediakan objek yang mengimplementasikan antarmuka TokenCredential. Jika tidak ditentukan, AnonymousCredential digunakan.

options
StoragePipelineOptions

Fakultatif. Opsi untuk mengonfigurasi alur HTTP.

Contoh menggunakan DefaultAzureCredential dari @azure/identity:

const account = "<storage account name>";

const defaultAzureCredential = new DefaultAzureCredential();

const blobChangeFeedClient = new BlobChangeFeedClient(
  `https://${account}.blob.core.windows.net`,
  defaultAzureCredential
);

Contoh menggunakan nama/kunci akun:

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

Detail Metode

fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)

Membuat instans BlobChangeFeedClient dari string koneksi.

static function fromConnectionString(connectionString: string, options?: StoragePipelineOptions, changeFeedClientOptions?: BlobChangeFeedClientOptions): BlobChangeFeedClient

Parameter

connectionString

string

String koneksi akun atau string koneksi SAS dari akun penyimpanan Azure. [ Catatan - String koneksi akun hanya dapat digunakan dalam runtime NODE.JS. ] Contoh string koneksi akun - contoh string koneksi SAS DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net - 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

Fakultatif. Opsi untuk mengonfigurasi alur HTTP.

changeFeedClientOptions
BlobChangeFeedClientOptions

Mengembalikan

listChanges(BlobChangeFeedListChangesOptions)

Mengembalikan iterator yang dapat diulang asinkron untuk mencantumkan semua peristiwa umpan perubahan di akun yang ditentukan.

.byPage() mengembalikan iterator yang dapat diulang asinkron untuk mencantumkan peristiwa umpan perubahan di halaman.

Contoh menggunakan sintaks for await:

let i = 1;
for await (const event of blobChangeFeedClient.listChanges()) {
  console.log(`Event ${i++}, type: ${event.eventType}`);
}

Contoh menggunakan 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();
}

Contoh menggunakan 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}`);
    }
  }
}

Contoh menggunakan halaman dengan penanda:

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>

Parameter

options
BlobChangeFeedListChangesOptions

Opsi untuk mencantumkan peristiwa feed perubahan.

Mengembalikan

AsyncIterableIterator yang mendukung halaman.