Partager via


BlobChangeFeedClient class

Constructeurs

BlobChangeFeedClient(string, Pipeline)

Crée une instance de BlobChangeFeedClient.

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

Crée une instance de BlobChangeFeedClient.

Méthodes

fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)

Crée une instance de BlobChangeFeedClient à partir de la chaîne de connexion.

listChanges(BlobChangeFeedListChangesOptions)

Retourne un itérateur itérable asynchrone pour répertorier tous les événements de flux de modification dans le compte spécifié.

.byPage() retourne un itérateur itérable asynchrone pour répertorier les événements de flux de modification dans les pages.

Exemple utilisant for await syntaxe :

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

Exemple utilisant 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();
}

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

Exemple d’utilisation de la pagination avec un marqueur :

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

Détails du constructeur

BlobChangeFeedClient(string, Pipeline)

Crée une instance de BlobChangeFeedClient.

new BlobChangeFeedClient(url: string, pipeline: Pipeline)

Paramètres

url

string

Chaîne cliente pointant vers le service d’objets blob Stockage Azure, par exemple «https://myaccount.blob.core.windows.net". Vous pouvez ajouter une SAP si vous utilisez AnonymousCredential, par exemple «https://myaccount.blob.core.windows.net?sasString".

pipeline
Pipeline

Appelez newPipeline() pour créer un pipeline par défaut ou fournissez un pipeline personnalisé.

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

Crée une instance de BlobChangeFeedClient.

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

Paramètres

url

string

Chaîne cliente pointant vers le service d’objets blob Stockage Azure, par exemple «https://myaccount.blob.core.windows.net". Vous pouvez ajouter une SAP si vous utilisez AnonymousCredential, par exemple «https://myaccount.blob.core.windows.net?sasString".

credential

StorageSharedKeyCredential | AnonymousCredential | TokenCredential

Tels que AnonymousCredential, StorageSharedKeyCredential ou toutes les informations d’identification du package @azure/identity pour authentifier les demandes auprès du service. Vous pouvez également fournir un objet qui implémente l’interface TokenCredential. Si ce n’est pas spécifié, AnonymousCredential est utilisé.

options
StoragePipelineOptions

Optionnel. Options de configuration du pipeline HTTP.

Exemple utilisant DefaultAzureCredential à partir de @azure/identity:

const account = "<storage account name>";

const defaultAzureCredential = new DefaultAzureCredential();

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

Exemple utilisant un nom/clé de compte :

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

Détails de la méthode

fromConnectionString(string, StoragePipelineOptions, BlobChangeFeedClientOptions)

Crée une instance de BlobChangeFeedClient à partir de la chaîne de connexion.

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

Paramètres

connectionString

string

Chaîne de connexion de compte ou chaîne de connexion SAP d’un compte de stockage Azure. [ Remarque : la chaîne de connexion de compte ne peut être utilisée que dans NODE.JS runtime. ] Exemple de chaîne de connexion de compte - exemple de chaîne de connexion 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

Optionnel. Options de configuration du pipeline HTTP.

changeFeedClientOptions
BlobChangeFeedClientOptions

Retours

listChanges(BlobChangeFeedListChangesOptions)

Retourne un itérateur itérable asynchrone pour répertorier tous les événements de flux de modification dans le compte spécifié.

.byPage() retourne un itérateur itérable asynchrone pour répertorier les événements de flux de modification dans les pages.

Exemple utilisant for await syntaxe :

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

Exemple utilisant 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();
}

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

Exemple d’utilisation de la pagination avec un marqueur :

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>

Paramètres

options
BlobChangeFeedListChangesOptions

Options pour lister les événements de changement de flux.

Retours

AsyncIterableIterator qui prend en charge la pagination.