Microsoft Azure service bus with VSTS

The Microsoft Azure service bus provides messaging between services and applications. You can choose the type of service bus you want to send VSTS messages to:

  • Queue: The Service Bus queue is a simple process. A sender sends a message to a queue, and a receiver picks up that message at a later time. A queue is limited to a single receiver.

  • Topics: Topics are similar to queues, but they let each receiving application create its own subscription by defining a filter. A subscriber will see only the messages that match that filter.

  • Notification hub: Use a notification hub to implement push notifications. Notification hubs work for both consumer and enterprise applications for mobile platforms including Windows Store, Windows Phone 8, IOS and Android.

Create a Microsoft Azure service bus namespace

  1. If you don't have a Microsoft Azure account, get one here.

  2. In the Microsoft Azure portal, in the navigation pane select SERVICE BUS and then create a new namespace.

    <img alt="Select or create a service bus" src="./_img/azure-service-bus/create-service-bus.jpg")>

  3. Enter a name for the namespace and choose a region.

    Specify namespace and region

  4. View the connection information for the namespace.

    View the connection information

  5. Copy the SAS connection string. You will need to provide this value when you create a Service Hook subscription.

    Copy the connection string

Send messages to the service bus queue

  1. In the Azure portal, verify the queue you want to use, or create one.

    Azure Service Bus Queue

  2. Create or modify your app's code to receive VSTS messages using a Azure Service Bus queue. For details, go here.

  3. Open the admin page for the team project in VSTS.

  4. On the Service Hooks tab, run the subscription wizard.

    For details about the subscription wizard, go here.

    Add a service hook

  5. Pick and configure the VSTS event.

    Configure the event

  6. Configure what to do when the action occurs. In this case, to send Visual Studio messages to a service bus queue. For the SAS connection string, use the value that you copied earlier from the namespace connection information page.

    Configure the action

  7. Test the service hook subscription and finish the wizard.

    Azure Service Bus Queue Test

Now the messages are set up. You can verify this in your application or service.

Send messages to the service bus topic

  1. In the Azure portal, verify the queue you want to use, or create one.

    Azure Service Bus Topic

  2. Create or modify your app's code to recieve VSTS messages using a Azure Service Bus topic. For details, go here.

  3. Open the admin page for the team project in VSTS.

  4. On the Service Hooks tab, run the subscription wizard.

    For details about the subscription wizard, go here.

    Add a service hook

  5. Pick and configure the VSTS event.

    Configure the event

  6. Configure what to do when the event occurs. In this case, to send Visual Studio messages to a service bus topic. For the SAS connection string, use the value that you copied earlier from the namespace connection information page.

    Configure the action

  7. Test the service hook subscription and finish the wizard.

    Azure Service Bus Topic Action

Now the messages are set up. You can verify this in your application or service.

You can also observe activity in the Windows Azure dashboard.

Azure Service Bus Topic Result

Send messages to the notification hub

Push VSTS messages to your application using a notification hub. For more information about notification hubs go here.

  1. In the Azure portal, verify the notification hub you want to use, or create one.

    Azure Service Bus notifications

  2. Create or modify an app to receive messages from VSTS through the notification hub. The steps and code required to set up your app depend on the target platform (Windows Store, Windows Phone 8, IOS, or Android). For details, go here.

  3. Open the admin page for the team project in VSTS.

  4. On the Service Hooks tab, run the subscription wizard.

    For details about the subscription wizard, go here.

    Add a sevice hook

  5. Pick and configure the VSTS event.

    Configure the event

  6. Configure what to do when the event occurs. In this case, to send Visual Studio messages to a service bus notification hub. For the SAS connection string, use the value that you copied earlier from the namespace connection information page. You can use tags to filter the messages to specific registered apps or users. For more information regarding tags go here.

    Configure the action

  7. Test the service hook subscription and finish the wizard.

Now the messages are set up. You can verify this in your application or service.

Pricing

VSTS doesn't charge for the framework for integrating with external services. Check out the specific service's site for pricing related to their services.

Q & A

Q: When using VSTS service hooks connected to a Azure notification hub, how do I pass parameters in a push notification template?

A: Use the following taking care to concatenate the variable and value in the param node:

    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<wp:notification wpnotification\"="" xmlns:wp="\">" +
            "<wp:toast>" +
                "<wp:param>" + "{'?VariableName='" + "$(parameter)" + "}</wp:param>" +
        "</wp:toast>" +
    "</wp:notification>";

Q: Can I get more information about the differences between service bus queues and service bus topics?

A: Get more details here.

Q: Can I programmatically create subscriptions?

A: Yes. See details here.