Skip to content

Forward messages from AWS SQS to Azure Service Bus via an Azure Logic App

License

Notifications You must be signed in to change notification settings

mattias-fjellstrom/aws-sqs-to-azure-servicebus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forward messages from AWS SQS to Azure Service Bus

This example demonstrates how to send messages from an SQS queue in AWS to a Service Bus queue in Azure by using a Logic App as the connection between the two queues.

Prerequisites

  • AWS CLI with a default profile and default region configured (install)
  • Azure CLI with a default subscription set (install)
  • Azure Bicep CLI (install with az bicep install)

Deploy AWS resources

Create an IAM user with access keys, and an SQS queue. If you already have a user and a queue you want to test with use them instead, but you need to provide the access keys and the queue URL to the Azure deployment yourself.

stackName=aws-sqs-to-azure-servicebus
aws cloudformation deploy \
    --stack-name $stackName \
    --template-file ./aws/deployment.yml \
    --capabilities CAPABILITY_IAM

sqsUrl=$(aws cloudformation describe-stacks \
    --stack-name $stackName \
    --query 'Stacks[].Outputs[?OutputKey==`SqsQueueUrl`].OutputValue' \
    --output text)

accessKeyId=$(aws cloudformation describe-stacks \
    --stack-name $stackName \
    --query 'Stacks[].Outputs[?OutputKey==`AccessKeyId`].OutputValue' \
    --output text)

secretAccessKey=$(aws cloudformation describe-stacks \
    --stack-name $stackName \
    --query 'Stacks[].Outputs[?OutputKey==`SecretAccessKey`].OutputValue' \
    --output text)

Deploy Azure resources

Create a resource group, a service bus namespace and queue, and a logic app with the required connections for SQS and Service Bus.

deploymentName=aws-sqs-to-azure-service-bus
az deployment sub create \
    --name $deploymentName \
    --location northeurope \
    --template-file ./azure/main.bicep \
    --parameters sqsQueueUrl=$sqsUrl awsAccessKeyId=$accessKeyId awsSecretAccessKey=$secretAccessKey

Test

Send a message to the SQS queue

Use the AWS CLI to send a message to the queue.

aws sqs send-message --queue-url $sqsUrl --message-body "This is my message"

Verify that the message has arrived in Service Bus queue

Use the Azure portal to verify that the message is received in the Service Bus queue.

  1. Go to the Azure portal
  2. Open your Service Bus namespace
  3. Click on queues and open the only queue in the list
  4. Open the Service Bus Explorer (preview) blade for the queue
  5. Click on the Receive tab and then on the Receive button
  6. Confirm that you want to perform the destructive action by clicking Yes
  7. The message is displayed on the bottom of the page, click on it to see the message content

Service Bus Explorer

Delete resources

Delete AWS resources.

aws cloudformation delete-stack --stack-name $stackName

Delete Azure resources. Note that there seems to be a delay of several minutes before the Azure subscription registers the deployment metadata. This means the first command below will not return the resource group name until this happens.

resourceGroupName=$(az deployment sub show \
    --name $deploymentName \
    --query 'properties.outputs.resourceGroupName.value' \
    --output tsv)
az group delete --name $resourceGroupName --yes --no-wait

About

Forward messages from AWS SQS to Azure Service Bus via an Azure Logic App

Topics

Resources

License

Stars

Watchers

Forks

Languages