Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main(): Promise {
// For now the interactive user needs to explicitly be assigned
// the role of a constributor/owner even if the user is a subscription owner.
// azure role assignment create -o contributor --scope /subscriptions//resourceGroups//providers/Microsoft.EventHub/namespaces/ --signInName
const credentials = await interactiveLogin({tokenAudience: aadEventHubsAudience});
const client = EventHubClient.createFromAadTokenCredentials(address, path, credentials);
const partitionIds = await client.getPartitionIds();
await client.send({ body: "Hello awesome world!!" }, partitionIds[0]);
const result: EventData[] = await client.receiveBatch(partitionIds[0], 2, 5, { eventPosition: EventPosition.fromEnqueuedTime(Date.now()) });
let i = 0;
for (const data of result) {
console.log("### Actual message (%d):", ++i, data.body);
}
await client.close();
}
async function main(): Promise {
const credentials = await interactiveLogin({ tokenAudience: "https://eventhubs.azure.net/" });
const client = EventHubClient.createFromAadTokenCredentials(evenHubsEndpoint, eventHubsName, credentials);
/*
Refer to other samples, and place your code here
to send/receive events
*/
await client.close();
}
async function main() {
const tokenCreds = await interactiveLogin({
tokenAudience: "https://servicebus.azure.net/"
});
const sbClient = ServiceBusClient.createFromAadTokenCredentials(serviceBusEndpoint, tokenCreds);
/*
Refer to other samples, and place your code here
to create queue clients, and send/receive messages
*/
await sbClient.close();
}
async function main(): Promise {
const tokenCreds = await interactiveLogin({
tokenAudience: "https://servicebus.azure.net/"
});
const sbClient = ServiceBusClient.createFromAadTokenCredentials(serviceBusEndpoint, tokenCreds);
/*
Refer to other samples, and place your code here
to create queue clients, and send/receive messages
*/
await sbClient.close();
}