-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lin Jian
committed
Jun 11, 2020
1 parent
eac19bb
commit 00e2401
Showing
8 changed files
with
136 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
sdk/storage/storage-blob-changefeed/samples/typscript/resume.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { BlobServiceClient, StorageSharedKeyCredential } from "@azure/storage-blob"; | ||
import { BlobChangeFeedClient, BlobChangeFeedEvent } from "../../src"; | ||
|
||
// Load the .env file if it exists | ||
import * as dotenv from "dotenv"; | ||
console.log(dotenv.config()); | ||
|
||
import { setLogLevel } from "@azure/logger"; | ||
setLogLevel("info"); | ||
|
||
export async function main() { | ||
// Enter your storage account name and shared key | ||
const account = process.env.ACCOUNT_NAME || ""; | ||
const accountKey = process.env.ACCOUNT_KEY || ""; | ||
|
||
// Use StorageSharedKeyCredential with storage account and account key | ||
// StorageSharedKeyCredential is only available in Node.js runtime, not in browsers | ||
const sharedKeyCredential = new StorageSharedKeyCredential(account, accountKey); | ||
const blobServiceClient = new BlobServiceClient( | ||
// When using AnonymousCredential, following url should include a valid SAS or support public access | ||
`https://${account}.blob.core.windows.net`, | ||
sharedKeyCredential | ||
); | ||
|
||
const changeFeedClient = new BlobChangeFeedClient(blobServiceClient); | ||
let changeFeedEvents: BlobChangeFeedEvent[] = []; | ||
const firstPage = await changeFeedClient.getChanges().byPage({ maxPageSize: 10 }).next(); | ||
for (const event of firstPage) { | ||
changeFeedEvents.push(event); | ||
} | ||
|
||
// Resume iterating from the pervious position with the continuationToken. | ||
for await (const eventPage of changeFeedClient.getChanges().byPage({ continuationToken: firstPage.continuationToken })) { | ||
for (const event of eventPage) { | ||
changeFeedEvents.push(event); | ||
} | ||
} | ||
} | ||
|
||
main().catch((err) => { | ||
console.error("Error running sample:", err.message); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters