Sending Messages to Azure Service Bus Queue Using Node.js
| March 10, 2023 | in
Azure Service Bus is an excellent glue technology that we can use to handle the communication between our subsystems. We often use Azure Service Bus as the “queue” between our subsystems, which works great.
We usually build our backend systems using C#/.NET, but what if we need to send a message using Node.js?
Node.js is one of the more popular backend technologies. While it’s not necessarily our first pick in backend technologies at Don’t Panic Labs, many solutions are already using it, and not adding more technologies can benefit a project. Luckily, it is very easy to send messages from Node.js.
First, go to the Azure portal and create a service bus.
Name your service bus.
Go to your newly created service bus service and create a queue.
Name your queue.
Create a shared access policy.
Since we will only be sending messages, let’s create a policy that only allows sending capabilities.
To send a message, we will first need to install some Node.js packages.
Npm install @azure/service-bus @azure/identity
After sending a few messages, we should see them appear in the portal.
Sending messages to a service bus queue is straightforward, even from Node.js. Are you using Node.js and Azure Service Bus? If so, shoot me a message on Twitter where I’m @chadmichel.