I received a “virtual assistant” as a gift this year and while I enjoy listening to music and quickly checking the weather forecast (spoiler: its always cold in Chicago), I love the idea of bringing the virtual assistant into the workplace. This week I decided to build learn more about building custom “Skills” and decided to put this to the test with Cortana and Azure administration.
I quickly came across the Cortana Dev Center, which provides an easy to use language and tool-set to develop Cortana skills. Rather than using C# or other programming language, Cortana Dev Center Skills are programmed using Semantic Composition Language (SCL). This is a great introductory programming language because its easy to read and understand.
Here’s a quick high-level architecture of what we’ll be deploying:
As someone who spends most of my days living inside the Azure portal, I thought it would be great if I could delegate some of my tasks to Cortana. I figured it would be cool if I could just ask Cortana to “fix this error”, but decided to set my sights a little lower…
So I imagined myself in the middle of lunch and receiving an email that I need to restart a VM ASAP. I pictured myself running to my computer, logging into Azure, finding the VM, performing a restart, confirming the machine comes back up, and then moving on, fairly simple process that takes maybe 5-10 minutes out of my lunch? But what if I could do it in 10 seconds…..
Create a Cortana Skill to Restart an Azure VM
Create a new Cortana Botlet
Start by signing into the Cortana Dev Center and create a new Cortana Skill. Follow the steps provided and fill out the information requested.
Add the Botlet code
Add the Code that will control the Skill. The code I created can be found here:
Add a new Runbook to your Azure Automation Account
Add a new Runbook to your Automation Account
Paste the Runbook code from here:
Create the Runbook Webhook
From within the Runbook, navigate to the Webhook and Create a New webhook. Give your webhook a name, and expiration. The URL will be autogenerated.
Add a new botlet service
Add a new service to the botlet solution
Add a description to the service and an image if desired
Choose the “I have a web service” option, and paste the Runbook Webhook URL. You’ll need to remove the “?token=asdf….” portion, but make sure you save that portion for the next step.
Update the Webhook URL to include the “?token=asdf1234…..”
Add an action to the Service.
Add the Action Parameters, in this case, VM name.
Test the solution by chatting with Cortana.
Sorry something went wrong? I spent about 20 minutes chasing this error before I realized that the Runbook was in fact executing and I seemed to be receiving a false positive. I believe the error was due to the Webhook not sending a result back.
Here we see the output of our Runbook
Azure Bot Services resources are available to deploy more robust chat bots as an Azure Web App or Azure Function.