|sendMessages.js||Demonstrates how to send messages to Service Bus Queue/Topic|
|receiveMessagesLoop.js||Demonstrates how to receive Service Bus messages in a loop|
|receiveMessagesStreaming.js||Demonstrates how to receive Service Bus messages in a stream|
|usingAadAuth.js||This sample how to create a namespace using AAD token credentials|
|browseMessages.js||Demonstrates how to browse a Service Bus message|
|session.js||Demonstrates how to send/receive messages to/from session enabled queues/subscriptions in Service Bus|
|scheduledMessages.js||Demonstrates how to schedule messages to appear on a Service Bus Queue/Subscription at a later time|
|useProxy.js||This sample demonstrates how to create a ServiceBusClient meant to be used in an environment where outgoing network requests have to go through a proxy server|
|advanced/administrationClient.js||Demonstrates how to manage the resources of a service bus namespace.|
|advanced/sessionRoundRobin.js||Demonstrates how to continually read through all the available sessions|
|advanced/deferral.js||Demonstrates how to defer a message for later processing.|
|advanced/listingEntities.js||Demonstrates how the ServiceBusAdministrationClient can be used to list the entities of a service bus namespace|
|advanced/sessionState.js||Demonstrates usage of SessionState.|
|advanced/movingMessagesToDLQ.js||Demonstrates scenarios as to how a Service Bus message can be explicitly moved to the DLQ|
|advanced/processMessageFromDLQ.js||Demonstrates retrieving a message from a dead letter queue, editing it and sending it back to the main queue|
The sample programs are compatible with LTS versions of Node.js.
You need an Azure subscription and the following Azure resources to run these sample programs:
Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function.
Adapting the samples to run in the browser may require some additional consideration. For details, please see the package README.
To run the samples using the published version of the package:
- Install the dependencies using
Edit the file
sample.env, adding the correct credentials to access the Azure service and run the samples. Then rename the file from
.env. The sample programs will read this file automatically.
Run whichever samples you like (note that some samples may require additional setup, see the table above):
Alternatively, run a single sample with the correct environment variables set (setting up the
.env file is not required if you do this), for example (cross-platform):
npx cross-env SERVICEBUS_CONNECTION_STRING="<servicebus connection string>" QUEUE_NAME="<queue name>" node sendMessages.js
Take a look at our API Documentation for more information about the APIs that are available in the clients.