BlobChangeFeedClient class
BlobChangeFeedClient.
Fare riferimento a https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
Costruttori
| Blob |
Crea un'istanza di BlobChangeFeedClient. |
| Blob |
Crea un'istanza di BlobChangeFeedClient. |
Metodi
| from |
Crea un'istanza di BlobChangeFeedClient dalla stringa di connessione. |
| list |
Restituisce un iteratore iteratore asincrono per elencare tutti gli eventi del feed di modifiche nell'account specificato. .byPage() restituisce un iteratore iteratore asincrono per elencare gli eventi del feed di modifiche nelle pagine. Esempio di utilizzo della sintassi
Esempio con
Esempio con
Esempio di utilizzo del paging con un marcatore:
|
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 pacchetto @azure/identity per autenticare le richieste al servizio. È anche possibile fornire un oggetto che implementa l'interfaccia TokenCredential. Se non specificato, viene utilizzato AnonymousCredential.
- options
- StoragePipelineOptions
Opzionale. 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 che usa un nome/chiave dell'account:
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 - Esempio di stringa di connessione 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
Opzionale. Opzioni per configurare la pipeline HTTP.
- changeFeedClientOptions
- BlobChangeFeedClientOptions
Restituisce
listChanges(BlobChangeFeedListChangesOptions)
Restituisce un iteratore iteratore asincrono per elencare tutti gli eventi del feed di modifiche nell'account specificato.
.byPage() restituisce un iteratore iteratore asincrono per elencare gli eventi del feed di modifiche nelle pagine.
Esempio di utilizzo della sintassi for await:
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 utilizzo 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.