Self Service Using Azure Runbooks & Fresh Service

I am not a fan of doing tasks manually. Whenever there is an opportunity to reduce work for myself in future by spending a bit longer to initially set something up, I will always do that. This article could be followed to achieve other ITSM automation goals using a webhook.

In this example I want to achieve a simple goal, of granting users access to Dynamics CRM online with a layer of approval. To achieve this I did the following

  1. Created a service offering in FreshService for users to access
  2. Created a rule to automatically ask for approval when that service (Dynamics CRM) has been requested. (Dispatch’r Rule in FreshService)
  3. On the event the request is approved, run a webhook with the requester’s email & the ticket ID (Observer Rule in FreshService)
  4. Webhook fires run book which then performs the task of adding user to a particular Office 365 Group, Send instructions to user, and then making a note on the ticket upon completion.
  5. Use Azure Active Directory to assign licenses to the same group.

FreshService

I won’t go into much detail here but the basic information you need to know is that FreshService supports webhooks. In my scenario I have two rules, 1 to trigger approval, 1 for the webhook once it has been approved. It is a simple interface, you enter the webhook URL with the content you would like to send in the request. You will get the URL in the next step.

FreshService Observer screen webhook

Runbook

The first step is to make a run book, and add a webhook. Webhook is a menu under the main runbook properties. When you create the runbook the url will be created, put this URL somewhere safe as you won’t be able to view it again after making it! The only parameter you need will be¬†WEBHOOKDATA which I will explain in a moment, or you can read this link which explains it also.

At the start of your runbook you want to define the WEBHOOKDATA parameter.

The next part is a conditional statement where you can put your code if the object WEBHOOKDATA has content.

The body of the request is within the WEBHOOKDATA object so you need to get the information out so that you can use it in your runbook.

Now that I have the information I want readily available (In the object $WebhookBody) I can do what I need to do, which in this case is add the user to a group which is tied to an Office 365 license.

License

I have assigned the group above in Azure Active Directory to assign the appropriate license. Under your directory go to Licenses, then click into the licence you want to assign.