Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function main(): Promise {
console.log(`Running sendEvents sample`);
const producer = new EventHubProducerClient(connectionString, eventHubName);
console.log("Creating and sending a batch of events...");
const eventsToSend = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"];
try {
// By not specifying a partition ID or a partition key we allow the server to choose
// which partition will accept this message.
//
// This pattern works well if the consumers of your events do not have any particular
// requirements about the ordering of batches against other batches or if you don't care
// which messages are assigned to which partition.
//
// If you would like more control you can pass either a `partitionKey` or a `partitionId`
// into the createBatch() `options` parameter which will allow you full control over the
// destination.