Condividi tramite


BlobChangeFeedClient class

Costruttori

BlobChangeFeedClient(string, Pipeline)

Crea un'istanza di BlobChangeFeedClient.

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

Crea un'istanza di BlobChangeFeedClient.

Metodi

fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)

Crea un'istanza di BlobChangeFeedClient dalla stringa di connessione.

listChanges(BlobChangeFeedListChangesOptions)

Restituisce un iteratore iteratore iterabile asincrono per elencare tutti gli eventi del feed di modifiche nell'account specificato.

.byPage() restituisce un iteratore iteratore iterabile asincrono per elencare gli eventi del feed di modifiche nelle pagine.

Esempio di uso for await della sintassi:

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

Esempio con 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();
}

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

Esempio di uso del paging con un marcatore:

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

Dettagli costruttore

BlobChangeFeedClient(string, Pipeline)

Crea un'istanza di BlobChangeFeedClient.

new BlobChangeFeedClient(url: string, pipeline: Pipeline)

Parametri

url

string

Stringa client che punta al servizio BLOB di Archiviazione di Azure, ad esempio "https://myaccount.blob.core.windows.net". È possibile aggiungere una firma di accesso condiviso se si usa AnonymousCredential, ad esempio "https://myaccount.blob.core.windows.net?sasString".

pipeline
Pipeline

Chiamare newPipeline() per creare una pipeline predefinita o fornire una pipeline personalizzata.

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

Crea un'istanza di BlobChangeFeedClient.

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

Parametri

url

string

Stringa client che punta al servizio BLOB di Archiviazione di Azure, ad esempio "https://myaccount.blob.core.windows.net". È possibile aggiungere una firma di accesso condiviso se si usa AnonymousCredential, ad esempio "https://myaccount.blob.core.windows.net?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Ad esempio AnonymousCredential, StorageSharedKeyCredential o qualsiasi credenziale del @azure/identity pacchetto per autenticare le richieste al servizio. È anche possibile fornire un oggetto che implementa l'interfaccia TokenCredential. Se non specificato, viene utilizzato AnonymousCredential.

options
StoragePipelineOptions

Facoltativa. Opzioni per configurare la pipeline HTTP.

Esempio di uso di DefaultAzureCredential da @azure/identity:

const account = "<storage account name>";

const defaultAzureCredential = new DefaultAzureCredential();

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

Esempio di uso di un nome account/chiave:

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

Dettagli metodo

fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)

Crea un'istanza di BlobChangeFeedClient dalla stringa di connessione.

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

Parametri

connectionString

string

Stringa di connessione dell'account o stringa di connessione sas di un account di archiviazione di Azure. [ Nota: la stringa di connessione dell'account può essere usata solo in NODE.JS runtime. ] Esempio di stringa di connessione dell'account -DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net Esempio di stringa di connessione di firma di accesso condiviso - 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

Facoltativa. Opzioni per configurare la pipeline HTTP.

changeFeedClientOptions
BlobChangeFeedClientOptions

Restituisce

listChanges(BlobChangeFeedListChangesOptions)

Restituisce un iteratore iteratore iterabile asincrono per elencare tutti gli eventi del feed di modifiche nell'account specificato.

.byPage() restituisce un iteratore iteratore iterabile asincrono per elencare gli eventi del feed di modifiche nelle pagine.

Esempio di uso for await della sintassi:

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

Esempio con 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();
}

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

Esempio di uso del paging con un marcatore:

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>

Parametri

options
BlobChangeFeedListChangesOptions

Opzioni per elencare gli eventi del feed di modifiche.

Restituisce

AsyncIterableIterator che supporta il paging.