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.
- 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
)
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)
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
Use the AWS CLI to send a message to the queue.
aws sqs send-message --queue-url $sqsUrl --message-body "This is my message"
Use the Azure portal to verify that the message is received in the Service Bus queue.
- Go to the Azure portal
- Open your Service Bus namespace
- Click on queues and open the only queue in the list
- Open the Service Bus Explorer (preview) blade for the queue
- Click on the Receive tab and then on the Receive button
- Confirm that you want to perform the destructive action by clicking Yes
- The message is displayed on the bottom of the page, click on it to see the message content
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