Introducing our new CEO Don Johnson - Read More

Azure Service Bus Emulator

Verified Publisher

azure-messaging/servicebus-emulator

By Microsoft

Created 3 months ago

Official image for Microsoft Azure Service Bus Emulator

1

About

Azure Service Bus emulator is designed to offer a local development experience for Azure Service Bus, enabling you to develop and test code against our services in isolation, free from cloud interference.

Featured Tags

docker pull mcr.microsoft.com/azure-messaging/servicebus-emulator

  • latest

Related Repositories

You can find more details on the GitHub Repository: https://github.com/Azure/azure-service-bus-emulator-installer

Configuration

Azure Service Bus emulator has dependency on SQL edge. Refer following section on how to run Service Bus emulator and make configuration changes.

Usage

  • To start the emulator, you should supply configuration for the entities you want to use. Save the below config locally as Config.json
{
  "UserConfig": {
    "Namespaces": [
      {
        "Name": "sbemulatorns",
        "Queues": [
          {
            "Name": "queue.1",
            "Properties": {
              "DeadLetteringOnMessageExpiration": false,
              "DefaultMessageTimeToLive": "PT1H",
              "DuplicateDetectionHistoryTimeWindow": "PT20S",
              "ForwardDeadLetteredMessagesTo": "",
              "ForwardTo": "",
              "LockDuration": "PT1M",
              "MaxDeliveryCount": 10,
              "RequiresDuplicateDetection": false,
              "RequiresSession": false
            }
          }
        ],
        "Topics": [
          {
            "Name": "topic.1",
            "Properties": {
              "DefaultMessageTimeToLive": "PT1H",
              "DuplicateDetectionHistoryTimeWindow": "PT20S",
              "RequiresDuplicateDetection": false
            },
            "Subscriptions": [
              {
                "Name": "subscription.1",
                "Properties": {
                  "DeadLetteringOnMessageExpiration": false,
                  "DefaultMessageTimeToLive": "PT1H",
                  "LockDuration": "PT1M",
                  "MaxDeliveryCount": 10,
                  "ForwardDeadLetteredMessagesTo": "",
                  "ForwardTo": "",
                  "RequiresSession": false
                },
                "Rules": [
                  {
                    "Name": "app-prop-filter-1",
                    "Properties": {
                      "FilterType": "Correlation",
                      "CorrelationFilter": {
                        "ContentType": "application/text",
                        "CorrelationId": "id1",
                        "Label": "subject1",
                        "MessageId": "msgid1",
                        "ReplyTo": "someQueue",
                        "ReplyToSessionId": "sessionId",
                        "SessionId": "session1",
                        "To": "xyz"
                      }
                    }
                  }
                ]
              },
              {
                "Name": "subscription.2",
                "Properties": {
                  "DeadLetteringOnMessageExpiration": false,
                  "DefaultMessageTimeToLive": "PT1H",
                  "LockDuration": "PT1M",
                  "MaxDeliveryCount": 10,
                  "ForwardDeadLetteredMessagesTo": "",
                  "ForwardTo": "",
                  "RequiresSession": false
                },
                "Rules": [
                  {
                    "Name": "user-prop-filter-1",
                    "Properties": {
                      "FilterType": "Correlation",
                      "CorrelationFilter": {
                        "Properties": {
                          "prop3": "value3"
                        }
                      }
                    }
                  }
                ]
              },
              {
                "Name": "subscription.3",
                "Properties": {
                  "DeadLetteringOnMessageExpiration": false,
                  "DefaultMessageTimeToLive": "PT1H",
                  "LockDuration": "PT1M",
                  "MaxDeliveryCount": 10,
                  "ForwardDeadLetteredMessagesTo": "",
                  "ForwardTo": "",
                  "RequiresSession": false
                }
              }
            ]
          }
        ]
      }
    ],
    "Logging": {
      "Type": "File"
    }
  }
}
  • Save below yaml file as docker-compose.yml to spin up containers for Service Bus emulator.
name: microsoft-azure-servicebus-emulator
services:
  emulator:
    container_name: "servicebus-emulator"
    image: mcr.microsoft.com/azure-messaging/servicebus-emulator:latest
    volumes:
      - "${CONFIG_PATH}:/ServiceBus_Emulator/ConfigFiles/Config.json"
    ports:
      - "5672:5672"
    environment:
      SQL_SERVER: sqledge  
      MSSQL_SA_PASSWORD: ${MSSQL_SA_PASSWORD}
      ACCEPT_EULA: ${ACCEPT_EULA}
    depends_on:
      - sqledge
    networks:
      sb-emulator:
        aliases:
          - "sb-emulator"
  sqledge:
        container_name: "sqledge"
        image: "mcr.microsoft.com/azure-sql-edge:latest"
        networks:
          sb-emulator:
            aliases:
              - "sqledge"
        environment:
          ACCEPT_EULA: ${ACCEPT_EULA}
          MSSQL_SA_PASSWORD: ${MSSQL_SA_PASSWORD}
networks:
  sb-emulator:
  • Create .env file to declare the environment variables for Service Bus emulator and ensure all of the following environment variables are set.
# Environment file for user defined variables in docker-compose.yml

# 1. CONFIG_PATH: Path to Config.json file
# Ex: CONFIG_PATH="C:\\Config\\Config.json"
CONFIG_PATH="<Replace with path to Config.json file>"

# 2. ACCEPT_EULA: Pass 'Y' to accept license terms for Azure SQL Edge and Azure Service Bus emulator.
# Service Bus emulator EULA : https://github.com/Azure/azure-service-bus-emulator-installer/blob/main/EMULATOR_EULA.txt
# SQL Edge EULA : https://go.microsoft.com/fwlink/?linkid=2139274
ACCEPT_EULA="N"

# 3. MSSQL_SA_PASSWORD to be filled by user as per policy : https://learn.microsoft.com/en-us/sql/relational-databases/security/strong-passwords?view=sql-server-linux-ver16 
MSSQL_SA_PASSWORD: ""

Note:

  • By passing the value "Y" to the environment variable "ACCEPT_EULA", you are acknowledging and accepting the terms and conditions of the End User License Agreement (EULA) for both Azure Service Bus emulator and Azure SQL Edge.

  • Ensure to place .env file in same directory to docker-compose.yaml file.

  • Set the MSSQL_SA_PASSWORD environment variable to a strong password of at least eight characters that meets the password requirements.

  • When specifying file paths in Windows, use double backslashes (\\) instead of single backslashes (\) to avoid issues with escape characters.


Run below command to run emulator
 docker compose -f <PathToDockerComposeFile> up -d
Interact with the emulator

Use the following connection string to interact with the emulator:

"Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;"

For variation in connection string with different scenarios, refer to the documentation.

You can also refer our installer repository to run Emulator using automated scripts.

Support

There is no official support provided for emulator.Any issues/suggestions should be reported via GitHub issues on installer repo.

Feedback

To provide feedback please use the following link Feedback.

License

  • Microsoft Containers Legal Notice: Container License Information
  • Azure Service Bus emulator : EULA
  • Azure SQL Edge Developer Edition: EULA
    • SQL Edge provides Developer and Premium editions, Service Bus Emulator relies on the Developer edition which is licensed for use as a development and test system and cannot be used in a production environment.

Docker Pull Command

docker pull mcr.microsoft.com/azure-messaging/servicebus-emulator