
Jira Cloud: Restart an Azure VM using JSM Assets and Automation
Atlassian recently introduced the ability to directly reboot an Azure virtual machine via Jira and Jira Service Management (JSM) automation. This feature helps streamline workflows, reduces manual intervention, and enhances incident response times. Unlike Azure Runbook functionality, which Atlassian has also introduced, this integration is more straightforward, easier to set up and maintain, and requires no scripting.
In this guide, I’ll walk you through setting up Jira Automation to trigger a virtual machine reboot within Azure. Additionally, I’ll include a layer of automation that leverages Jira Service Management’s Assets function within a ticket for better visibility and functionality. Let’s get started.
Jira Service Management – Assets
A significant part of JSM is the Asset functionality. You can track anything from laptops to services. I review some of the Asset setups in another post. For this guide, I have a Virtual machine, Dave-Test-Windows-Server, logged into Assets. I have filled out some basic information along with the server name.
Here is my Asset object example:
When a reporter opens a ticket, in our case, it is a server issue ticket. They are presented with a custom field named IT Server, which pulls from the Asset object list of servers.
This is handy for your team to see an object within the ticket without having to leave the ticket.
Jira allows you to add or subtract whatever fields you wish to be visible within the custom field.
For this guide, we’ll use the chosen Asset object data to set up automation to restart the Azure virtual machine.
Create Jira Automation
To create the automation, go to your Jira project settings. You will need administrator access to the project to do this. In the left pane, choose Automation. Then Click Create Rule.
First, we need to choose our trigger. In our case, our Support Team will change the ticket status from In Progress to Restart Server.
We’re going to set an issue field condition.
- Choose the IF: Add a condition
- For Field, find Issue Type
- The condition will be Equals
- Value = Server Issue.
- Click Next.
Next, we want to set up a branch. Click the + to add a component. Choose For Each: Add a branch. Choose Branch rile /related issues. Choose Current Issue under the Type of Created Issue. This is saying we ONLY want this automation to work on the issue that triggered it.
Choose to add a THEN: Add an action once your branch has been created.
- Search for Create variable
- Give the Variable a name. We’re going to use ProblemServer
- Set a smart value; in this case, since our user is picking a server from a custom field, we need to use that. Check out this quick how-to guide if you need help locating the Jira custom field ID.
- Click Next.
Choose to add a THEN: Add an action again. This time, choose Log Action.
We will log the action in the automation log if we need to troubleshoot this further. For our message, we are going to use:
Problem Server: {{ProblemServer}}
Choose to add a THEN: Add an action. Search and choose Lookup Objects.
This function searches JSM Assets based on your asset query. Here is how we’re basing our Lookup:
Let’s log our lookup into our automation log. Choose to add a THEN: Add an action again, search for Log action. For our message, well, simply add:
Object Lookup: {{lookupObjects.Name}}
The {{lookupObjects}} smart value is from our Lookup action. Adding the .Name
will get the object name instead of the object Key (defualt). We want this name to be used for our Azure server restart condition.
Add an IF: Add an action component. Search and choose the {{smart values}} condition.
- For the first value, we will use the
{{lookupObjects.Name}}
- The condition will be Equals
- The second value is our server name. In this case, the Dave-Test-Windows-Server
- Click Next
By adding this condition, we’re saying that if the object or server, in our case, the name within the custom field, is equal to Dave-Test-Windows-Server, then continue to the following action.
Add an IF: Add a component again. This time, choose Restart Virtual Machine in Azure.
- Sign in to Azure if it hasn’t already done so. I highly recommend using a service account setup instead of logging in with your login. Otherwise, everything will be logged under your account name, and in the worst case, if you get off-boarded, this automation will stop.
- Choose your subscription
- Select your Azure Resource Group
- Select the virtual machine. In our case, our Dave Test machine.
- I’m hoping Atlassian allows for smart value here at some point. This could make automation even more effortless to set up for multiple machines.
- Click Next.
In the last action step, we will add a Comment to let the ticket watchers know the server is being rebooted.
- Choose + and add an IF: Add an action component. Search for Add comment to the issue.
- Enter the comment you wish. This supports using Jira smart values.
- Click Next.
It’s time to save your rule and name it. Make sure you turn it on!
Ok, the Jira automation rule should now be set up.
Test the Automation!
As we mentioned, we want this restart to be triggered by a Jira ticket. We’ve already created our test ticket and added some information, including choosing an Object from the assets selection.
We will transition our ticket from In Progress to Restart Server to trigger the automation.
Select the Audit log at the top if you return to your automation rule. You should see all the Log actions we set up, including the command for restart of the Azure virtual machine.
If we go into the Azure Portal, find our Virtual Machine, and choose Activity Log. We can see the Restart Operation was triggered. If you note the event initiated, it may be necessary to use the Service Account to connect your Jira Automation to Azure.
Lastly, if we bounce back into the Jira Ticket, we should see the comment on the ticket.
You have successfully set up Azure Virtual Server reboot automation using Jira Automation with the new Restart Azure Virtual Machine function. Alternatively, those with more PowerShell experience could use Azure Runbooks. This approach provides greater flexibility and enhanced logging capabilities.
I hope you found this helpful!
Categories
Recent Posts
- PowerShell: How to Add an Alias to Every Users Mailbox and Groups in Microsoft 365
- Slack: Disable Entra ID User using a slash command.
- Slack: Retrieve Entra ID (MS365) User Information with a slash command.
- Jira Cloud: Disabling Entra ID User Accounts via Automation and Microsoft Runbook
- Jira Cloud: Restart an Azure VM using JSM Assets and Automation