-
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.
Enable rollup for browser with sample (#3206)
* Enable rollup for browser with sample
- Loading branch information
Showing
5 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the MIT Licence. | ||
This sample demonstrates a simple send event operation. | ||
Refer to other samples and replace code in main() to try them out --> | ||
|
||
<!-- Line that imports the SDK source script for use in browser --> | ||
<script src="../browser/event-hubs.js"></script> | ||
|
||
<script> | ||
// EventHubClient holds reference to the EventHubClient global object exposed by the imported script | ||
const EventHubClient = Azure.Messaging.EventHubs.EventHubClient; | ||
|
||
const connectionString = ""; | ||
const eventHubName = ""; | ||
|
||
async function main() { | ||
// Creates the instance of EventHubClient using input connection string | ||
// Refer to SDK documentation and other samples for more usage related information | ||
const client = EventHubClient.createFromConnectionString(connectionString, eventHubName); | ||
|
||
const partitionIds = await client.getPartitionIds(); | ||
|
||
// NOTE: For receiving events from Azure Stream Analytics, please send Events to an EventHub | ||
// where the body is a JSON object/array. | ||
const eventData = { body: { message: `Hello World! ...` } }; | ||
console.log(`Sending event: ${eventData.body.message}`); | ||
await client.send(eventData, partitionIds[0]); | ||
|
||
await client.close(); | ||
} | ||
|
||
main().catch(err => { | ||
console.log("Error occurred: ", err); | ||
}); | ||
</script> |
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