Skip to content

Creates a short living Azure Service Bus. Because Azure doesn't have a emulator, use this for integration tests etcetera.

Notifications You must be signed in to change notification settings

m-v-k/servicebus-cloner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Clones a Azure Service Bus by creating a new one and cloning all queues, topics and subscriptions into it, when ready outputs the connectionstring. Because Azure doesn't have a emulator, use this for automation such as integration tests. When ready, run again with --delete to cleanup the temporary Azure resource(s).

Docker Hub

PR's and issues are welcome.

Requirements

  • Docker.
  • Azure service principal with Azure Service Bus Data Owner and Contributor on subscription level or replace Contributor with a custom one with resource group write/read/list (Microsoft.Resources/resourceGroups/write).

Example

  1. Create a clone.

    output_string=$(docker run --rm servicebus-cloner:latest \
        --tenant=a2c511af-be9b-4d4f-a265-d2a3fcf3dc98 \
        --subscription=89d5e09c-47ac-4008-8b09-3f6e67c682eb \
        --clientid=5bc23718-68c1-472c-9a82-6c73f48d049d \
        --clientsecret=MySuperSecret \
        --sbFrom=MyRealServiceBusName \
        --sbTo=MyTemporaryServiceBusForTesting)
  2. Run your tests

    dotnet test -e "ServiceBusConnectionString=$output_string"
  3. Clean up resources

    docker run --rm servicebus-cloner:latest \
        --tenant=a2c511af-be9b-4d4f-a265-d2a3fcf3dc98 \
        --subscription=89d5e09c-47ac-4008-8b09-3f6e67c682eb \
        --clientid=5bc23718-68c1-472c-9a82-6c73f48d049d \
        --clientsecret=MySuperSecret \
        --sbTo=MyTemporaryServiceBusNameForTesting \
        --action=delete

Ephemeral

For some use cases, like docker-compose,it can be benificial to use the ephemeral flag. The test service will exist while the container runs. It is deleted on container SIGTERM. Use a volume to fetch the created connectionstring from the container.

docker run -v "mypath:/app/out" 
    --rm servicebus-cloner:latest \
    --out=/app/out/connectionstring \
    --tenant=a2c511af-be9b-4d4f-a265-d2a3fcf3dc98 \
    --subscription=89d5e09c-47ac-4008-8b09-3f6e67c682eb \
    --clientid=5bc23718-68c1-472c-9a82-6c73f48d049d \
    --clientsecret=MySuperSecret \
    --sbFrom=MyRealServiceBusName \
    --sbTo=MyTemporaryServiceBusForTesting \
    --action=ephemeral

About

Creates a short living Azure Service Bus. Because Azure doesn't have a emulator, use this for integration tests etcetera.

Resources

Stars

Watchers

Forks

Packages

No packages published