Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

Start Automation Runbooks in Response to Events in Visual Studio Online

$
0
0

If you weren’t able to attend //Build or Ignite last month, hopefully you’ve had the chance to watch some of the recorded sessions on the great new features coming to Microsoft’s suites of products.  Personally, the two I’m most excited about are Visual Studio Online (VSO) and Azure Automation.  These two services will be of great assistance in your Application Lifecycle Management (ALM)/DevOps journey.

Of all the current and soon to be released features in VSO, what’s caught my eye lately are the extensibility options.  One option announced last year is Service Hooks.  Service Hooks let you perform tasks on other services when something happens in a VSO project (e.g. new build created, work item updated, etc.).  One of the available services is a Webhook.  A Webhook can post JSON data about the event from VSO to any URL of your choice.  Enter Azure Automation!

With the recent announcement of Azure Automation Webhooks, you can trigger a custom runbook hosted in Azure to perform any action you want when an event happens in VSO.  Is that not awesome!?  Think of the possibilities this could open for your DevOps ambitions!

Creating a Webhook and VSO Service Hook

To show you how this works, I created a Runbook in Azure Automation that will receive data from VSO and email it out (via O365) to the addresses specified.  Here are the steps to set up this runbook.

  1. Browse to http://portal.azure.com and login to your organization’s Azure subscription.  From here, click on Browse –> Automation Accounts.
  2. On the Automation Accounts blade, you can choose to create a new account or put the Runbook in an existing Automation Account.
  3. From the Automation Account, click on Assets –> Credentials.  Create a new credential containing the username/password of the user you’d like to have send the email.  Make note of the name you assign to the credential.Start Automation Runbooks in Response to Events in Visual Studio Online
  4. Browse to Microsoft Script Center and download the Send-VsoEmail runbook.Start Automation Runbooks in Response to Events in Visual Studio Online
  5. Open the script and find the “Manually configured variables” section on line #27.  Make the following changes per your environment:
    1. Line #28 – Update the credential asset name to what you set up in Step #3.
    2. Line #29 – Update the array of email addresses that will be added to the To field of the email.
    3. Line #30 – Update the SMTP server you wish to use.
  6. Browse back to the Automation Account and from there, click Add a runbook –> Import an existing runbook.  Select the file you modified from Step #5 and it will create the Send-VsoEmail Runbook.
    NOTE:  The runbook will be created with the same name as the file.  If you would like to use a different name, simply rename the file before importing.Start Automation Runbooks in Response to Events in Visual Studio OnlineStart Automation Runbooks in Response to Events in Visual Studio Online
  7. You should now have a Runbook in your environment that looks like this.Start Automation Runbooks in Response to Events in Visual Studio Online
  8. Next, we need to create a Webhook in Azure Automation, allowing us to kick off this Runbook from VSO.  From the Send-VsoEmail Runbook, click on Webhooks –> Create new webhook.  We now have a Webhook that allows us to call that Runbook from VSO (or really anywhere for that matter).
    NOTE:  Make sure you save the URL, because once you click Create, there is no way to retrieve it again.Start Automation Runbooks in Response to Events in Visual Studio Online
  9. Browse to your Visual Studio Online account and the project you wish to integrate with.  From the project home page, click on the gear in the top-right corner.Start Automation Runbooks in Response to Events in Visual Studio Online
  10. From the control panel page, click on the Service Hooks tab. Then create a new Web Hook subscription.
    Start Automation Runbooks in Response to Events in Visual Studio Online
  11. Set the Trigger value to Work item created. You can build integrations off any of the events listed but we’ll use this one for our purposes.
    Start Automation Runbooks in Response to Events in Visual Studio Online
  12. In the URL field, enter the Webhook URL created from Step #8.  You have the option to configure additional settings, but for our purpose we’ll configure it as shown below  Then click Test.
    NOTE: For our email to pull the data correctly, you must at a minimum send the Resource details.
    Start Automation Runbooks in Response to Events in Visual Studio Online
  13. When you click Test, it will send test data to our Azure Automation Runbook via the Webhook.  Assuming everything is OK, you should get a success message like below.Start Automation Runbooks in Response to Events in Visual Studio Online
  14. Since our test is a live test that actually starts the runbook, you should receive an email containing the test VSO data.Start Automation Runbooks in Response to Events in Visual Studio Online
  15. To conclude our test, let’s create a real VSO work item and make sure it works.  Browse to the Backlog view of your VSO project and create a new Work Item.Start Automation Runbooks in Response to Events in Visual Studio Online
  16. We should now get a new email, notifying us of the new backlog item that was created!Start Automation Runbooks in Response to Events in Visual Studio Online

And there you have it!  You now have the power to build all sorts of cool integrations using Visual Studio Online Service Hooks, but that’s not all!  VSO is just one example of the many integration possibilities of using Webhooks.  This functionality could work easily with other applications like GitHub, Azure Scheduler or really any custom application.  Well done!

Just getting started with Azure Automation?  Learn about the service here, and follow Azure Automation on Twitter.


Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>