Fastify Azure Service Bus
This is a proof of concept on how to implement fastify with azure service bus within docker. This poc also follows code folder structure set by the team.
Pre-requisite
- Connect to Linux VM via SSH by running the power shell script.
- Add a queue named “message-queue” in your Azure Service Bus
- Pull the lts:node docker image before proceeding. If not, run below command
Initialization
Steps:
- Create a working directory
- Run and create a container
- Initialize the node project
- Install packages and Dependencies
- Initialize tsconfig.json file
- Add a new script in package.json
- Add code to your project
.env
src\api\controllers\messageController.ts
src\api\routes\messageRoutes.ts
src\api\routes\index.ts
src\config\index.ts
src\plugins\azureServiceBusPlugin.ts
src\services\azureServiceBusService.ts
src\types\message.d.ts
src\server.ts
Running the application
To run the application, execute below command while on docker run. This will run on http://localhost:3000
Test the api
- Sending a message to Azure Service Bus
- Read the message in Azure Service Bus
Verification
Connect to Azure Service Bus and look for the queue in which the message was sent.