-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[event-hubs] Updating samples folder to make it a standalone project #6413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
richardpark-msft
merged 15 commits into
Azure:master
from
richardpark-msft:richardpark-eh-ga-samples
Dec 10, 2019
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
62c25e9
Updating samples folder to make it a standalone project
richardpark-msft e35ca31
Standardizing the boilerplate
richardpark-msft bd454a7
Whoops, missed the azure-
richardpark-msft fc47eab
Make the sendEvents.ts a bit more illustrative of how you'd send mult…
richardpark-msft b922042
Make the tsconfig file standalone (no relative references)
richardpark-msft f19de42
Fix silly formatting error
richardpark-msft 775b844
Moving some of the ugliness into a sampleHelpers.ts file to make the …
richardpark-msft 08c29ed
Whoops, ordering matters. Moving the import back up top to ensure the…
richardpark-msft 41de2ca
We never intend to publish this
richardpark-msft 79fe18b
Copyright and remove unneeded import
richardpark-msft 2948bd1
* My keywords were totally bogus. Fixing...
richardpark-msft ca66ab0
Folder for runsamples was incorrect (although it's not really used si…
richardpark-msft 2b3f2ca
Updated with the proper paths for the node_modules folder
richardpark-msft 766f2ae
Added in missing packages
richardpark-msft 3a0ab7d
Make cleanup more robust
richardpark-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,41 @@ | ||
| { | ||
| "name": "azure-event-hubs-samples", | ||
| "private": true, | ||
| "version": "1.0.0", | ||
| "description": "The samples in this folder are for version 5.0.0 and above of this library. If you are using version 2.1.0 or lower, then please use [samples for v2.1.0](https://github.com/Azure/azure-sdk-for-js/tree/%40azure/event-hubs_2.1.0/sdk/eventhub/event-hubs/samples) instead", | ||
| "main": "dist-esm/runsamples.js", | ||
| "scripts": { | ||
| "samples": "ts-node ./runsamples.ts", | ||
| "build": "tsc -p ." | ||
| }, | ||
| "keywords": [ | ||
| "Azure", | ||
| "EventHubs", | ||
| "CheckpointStore", | ||
| "Node.js", | ||
| "TypeScript" | ||
| ], | ||
| "author": "Microsoft Corporation", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "url": "https://github.com/Azure/azure-sdk-for-js/issues" | ||
| }, | ||
| "homepage": "https://github.com/Azure/azure-sdk-for-js#readme", | ||
| "devDependencies": { | ||
| "ts-node": "^8.5.4", | ||
| "typescript": "^3.7.2", | ||
| "@types/node": "^12.12.17" | ||
| }, | ||
| "dependencies": { | ||
|
richardpark-msft marked this conversation as resolved.
|
||
| "@azure/core-amqp": "next", | ||
|
richardpark-msft marked this conversation as resolved.
|
||
| "@azure/event-hubs": "next", | ||
| "@azure/eventhubs-checkpointstore-blob": "next", | ||
| "@types/dotenv": "^8.2.0", | ||
| "@types/ws": "^6.0.4", | ||
| "dotenv": "^8.2.0", | ||
| "https-proxy-agent": "^3.0.1", | ||
| "rhea-promise": "^1.0.0", | ||
| "tslib": "^1.9.3", | ||
| "ws": "^7.2.0" | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import * as dotenv from "dotenv"; | ||
|
richardpark-msft marked this conversation as resolved.
|
||
|
|
||
| dotenv.config(); | ||
|
richardpark-msft marked this conversation as resolved.
|
||
|
|
||
| // don't have the samples execute - we'll run them manually in `main` below | ||
| process.env["DO_NOT_EXECUTE_SAMPLE"] = "1"; | ||
|
|
||
| import { main as sendEventsMain } from "./sendEvents"; | ||
| import { main as receiveEventsMain } from "./receiveEvents"; | ||
| import { main as receiveEventsUsingCheckpointStoreMain } from "./receiveEventsUsingCheckpointStore"; | ||
| import { main as useWithIotHubMain } from "./useWithIotHub"; | ||
| import { main as usingAadAuthMain } from "./usingAadAuth"; | ||
| import { main as websocketsMain } from "./websockets"; | ||
|
|
||
| async function main() { | ||
|
richardpark-msft marked this conversation as resolved.
|
||
| await sendEventsMain(); | ||
| await receiveEventsMain(); | ||
| await receiveEventsUsingCheckpointStoreMain(); | ||
| await useWithIotHubMain(); | ||
| await usingAadAuthMain(); | ||
| await websocketsMain(); | ||
| } | ||
|
|
||
| main().catch(err => { | ||
| console.log(err); | ||
| process.exit(1); | ||
| }) | ||
This file contains hidden or 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,28 @@ | ||
| # Used in most samples | ||
| EVENTHUB_CONNECTION_STRING=<connection string WITHOUT an EntityPath> | ||
| EVENTHUB_NAME=<name of a single eventhub> | ||
| EVENTHUB_FQDN=<your-eventhubs-namespace>.servicebus.windows.net | ||
| CONSUMER_GROUP_NAME=<name of a consumer group> | ||
|
|
||
| # Used in the receiveEventsUsingCheckpointStore.ts sample | ||
| STORAGE_CONTAINER_NAME=<storage account connection string for checkpoints> | ||
|
|
||
| # Used in the useWithIotHub.ts sample | ||
| IOTHUB_CONNECTION_STRING=<connection string with EntityPath> | ||
|
|
||
| # Used in the usingAadAuth.ts sample | ||
| # Setup : | ||
| # Please ensure that your Azure Event Hubs resource is in US East, US East 2, or West Europe | ||
| # region. AAD Role Based Access Control is not supported in other regions yet. | ||
| # Register a new application in AAD and assign the "Azure Event Hubs Data Owner (Preview)" role to it | ||
| # - See https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app | ||
| # to register a new application in the Azure Active Directory. | ||
| # - Note down the CLIENT_ID and TENANT_ID from the above step. | ||
| # - In the "Certificates & Secrets" tab, create a secret and note that down. | ||
| # - In the Azure portal, go to your Even Hubs resource and click on the Access control (IAM) | ||
| # tab. Here, assign the "Azure Event Hubs Data Owner (Preview)" role to the registered application. | ||
| # - For more information on Event Hubs RBAC setup, learn more at | ||
| # https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-role-based-access-control) | ||
| AZURE_CLIENT_ID= | ||
| AZURE_TENANT_ID= | ||
| AZURE_CLIENT_SECRET= |
This file contains hidden or 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 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import * as dotenv from "dotenv"; | ||
|
|
||
| // initialize using the .env file in the current folder | ||
| dotenv.config(); | ||
|
|
||
| /** | ||
| * Runs the async sample function, exiting if needed if it fails. | ||
| * @param main The 'main' function for the sample. | ||
| */ | ||
| export function runSample(main: () => Promise<void>) { | ||
| if (process.env["DO_NOT_EXECUTE_SAMPLE"]) { | ||
| return Promise.resolve(); | ||
| } | ||
|
|
||
| return main().catch((err) => { | ||
| console.log("Error occurred: ", err); | ||
| process.exit(1); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Runs your cleanupFn after waiting for `timeToWaitInSeconds` seconds | ||
| * @param cleanupFn Cleanup function to run. | ||
| * @param timeToWaitInSeconds Seconds to wait. | ||
| */ | ||
| export function cleanupAfterWaiting(cleanupFn: () => Promise<void>, timeToWaitInSeconds: number): Promise<void> { | ||
| return new Promise((resolve, reject) => { | ||
| console.log(`Waiting for ${timeToWaitInSeconds} seconds...`) | ||
|
|
||
| setTimeout(async () => { | ||
| try { | ||
| await cleanupFn(); | ||
| resolve(); | ||
| } catch (err) { | ||
| reject(err); | ||
| } | ||
| }, timeToWaitInSeconds * 1000); | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.