Introduction
In part two of this multi part blog series, we covered how to configure OMS to collect data through integration with System Center Operations Manager (SCOM), and through direct connections to individual servers. We also covered how Microsoft Operations Management Suite uses Solutions to deliver insights into your log data by providing a cost-effective, all-in-one cloud management solution so you can better protect guest workloads in Azure, AWS, Windows Server, Linux, VMWare, and Open Stack.
In the third part, Part III: we will cover how to configure automation for OMS.
Runbooks are workflows that perform an administrative process. The good news is you do not have to create all runbooks from scratch. Workflows can be uploaded to Azure from the Azure Runbook Gallery, the Microsoft Script Center, Microsoft MSDN and TechNet libraries, and the Azure community forums. OMS leverages the runbook capabilities of Microsoft Azure.
If you want to follow along, please ensure that Part I and Part II of this multi part blog series has been successfully completed.
Infrastructure Overview
We have the following servers installed in our demo environment:
- Domain controller, DNS, WSUS.
- System Center Operations Manager 2012 R2 with update Rollup 9.
- SQL Server holding SCOM databases.
- Linux Server (Ubuntu).
Introduction to OMS Runbooks
In this section, you will learn how to create and manage runbooks.
Step 1 – Configure Azure Automation Assets
In this step, you will create a credential asset for use in the creation of runbooks.
- Login to your SQL Server
- Sign in Operations Management Suite Portal at http://www.microsoft.com/en-us/server-cloud/operations-management-suite/overview.aspx
- On the OMS Overview blade, click Automation. If you recall, this is the account we created in Part I.
- Click the Runbooks Microsoft Azure Portal will open.
- On the Assets blade, click AzureOMSAutomation
- Under Resources, click Assets as shown in the following screenshot.
- On the Credential blade, click Credentials.
- Click +Add a credential.
- In the name field, type OMS Account.
- In the User name and password fields, type the credentials used to log in to OMS and click Create.
Note: In a production environment, you would need to use an organizational account. The Credential asset will not function correctly when a Microsoft account (i.e., outlook.com or live.com) is used.
- Close all blades and return to the Start board.
Step 2 – Create a Runbook from Scratch
In this section, you will create a runbook from scratch.
- Login to your SQL Server machine.
- Sign in to Operations Management Suite Portal at http://www.microsoft.com/en-us/server-cloud/operations-management-suite/overview.aspx
- Switch to the OMS Portal, OMS Automation
- Click Create a runbook. Microsoft Azure Portal will open.
- On the Assets blade, click AzureOMSAutomation
- Under Resources, click Runbooks.
- On the Runbook page, click +Add a runbook.
- On the Add Runbook page, click Create a new runbook.
- In the Runbook blade, type Write-HybridOMS as a Name.
- From the Runbook type drop-down menu, select PowerShell Workflow, click Create.
- Ensure that the correct Automation account, subscription, and region are selected and click Create.
- In the script area, edit the text to match the following:
- Click Save.
Step 3 – Test and Publish a Runbook
In this step, we will test and publish a runbook.
- In the Edit PowerShell Workflow Runbook blade for Write-HybridOMS, click Test Pane.
- Click Start.
- When you click, a runbook job is created and its status displayed in the pane. The job status will start as Queued indicating that it is waiting for a runbook worker in the cloud to come available. It will then move to Starting when a worker claims the job, and then Running when the runbook actually starts running. Please note it will take couple of minutes to complete.
- When the runbook job completes, its output is displayed as shown in the following screenshot. In this case, you should see Hybrid OMS.
- Close the Test blade to return to the canvas.
- Switch to the Edit PowerShell Workflow Runbook blade in the Azure Portal.
- Click Publish and then click Yes. The runbook will be published.
- Switch to the OMS Portal, click on Automation. As you can see in the following screenshot, we have additional runbook now.
In this step, we will edit a runbook.
- Login to your SQL Server
- Switch to the Edit PowerShell Workflow Runbook blade in the Azure Portal.
- In the Write-HybridOMS blade, Click Edit.
- Change “$Name = OMS” to “$Name = Azure”.
- Click Save.
- Click Revert to published and click Yes. This will discard all changes you have made and revert to the last published version.
- Close the Write-HybridOMS blade.
Step 5 – Start a Runbook
In this step, we will start a runbook manually and as a scheduled task.
- Login to your SQL Server
- Switch to Runbook blade in the Azure Portal, Click on Write-HybridOMS
- In the Write-HybridOMS blade, Click Start.
- In the Start Runbook blade, click OK.
When the runbook starts, a job pane is opened for the runbook job that you just created. The job status is shown in Job Summary and matches the statuses that you saw when you tested the runbook.
- When the job completed, click Output.
- The Output blade is opened; you can see “Hybrid OMS” as shown in the following screenshot
- Close the Output blade and the Job blade.
- Switch to the OMS Portal and click on the Overview In the Automation tile, “Jobs in the last 7 days” will have increased by 1 as shown in the following screenshot.
- Switch to the Job blade in the Microsoft Azure Portal.
- Close the Job blade.
- In the Write-HybridOMS blade, click Schedule.
- In the Schedule Runbook blade, click Link a schedule to your runbook.
- Click +Create a new schedule.
- In Name, type Daily.
- Change the time to 5 minutes from the current time. The start time must be at least 5 minutes after the time you create the schedule.
- From the Recurrence drop-menu, select Daily.
- Click Create.
- In the Schedule Runbook blade, click OK. The runbook will launch according to the schedule. When the job completes, “Jobs in the last 7 days” will increase by 1, so the total will be 2 as shown below:
- Leave the Microsoft Azure portal window open for the next steps.
Step 6 – Delete a Runbook
In this step, we will delete a runbook.
- Login to your SQL Server machine.
- Sign in to Operations Management Suite Portal at http://www.microsoft.com/en-us/server-cloud/operations-management-suite/overview.aspx
- Switch to the OMS Portal, OMS Automation
- Click the Runbooks Microsoft Azure Portal will open.
- Select Write-HybridOMS.
- In the Write-HybridOMS blade, click Delete and click Yes. The runbook is removed from the list of Runbooks.
- Switch to the OMS Portal and lick the Overview In the Automation tile, the number of runbooks is reduced by 1.
Step 7 – Import a Workflow to an OMS Runbook
In this step, we will import an existing workflow from the Microsoft Marketplace.
- Login to your SQL Server
- Sign in to Operations Management Suite Portal at http://www.microsoft.com/en-us/server-cloud/operations-management-suite/overview.aspx
- Click the Automation tile and note the number of Runbooks, we have one runbook.
- Click Runbooks. Microsoft Azure Portal will open.
- On the Dashboard blade, click AzureOMSAutomation.
- Under Resources, click
- On the Runbooks blade, click Browse gallery. Note that a larger number of runbooks are available from this location, as runbooks provided by community members are included in this view.
- In the Search box, type Create.
- In the results, click Create a new Virtual (VM) on Azure. Note that you can preview the contents of the runbook.
- In the Create a new Virtual Machine (VM) on Azure blade, click Import.
- In the import blade, click OK.
- Close open blades to return to the Runbooks
- Click New-AzureVMSample.
- In the New-AzureVMSample blade, click Edit. Note additional parameters are required for this runbook. Due to the fact that this is a new Azure environment, we have not yet created the virtual network necessary in Azure to support the creation of Virtual Machines.
- In the Runbook blade, click Publish and click Yes.
- Close the Azure Portal.
- In the OMS Portal, click the Overview Note the Automation tile, “Runbook” has increased by 1.
Creating a Graphic-Style Runbook
In this section, we will create a simple graphic-style runbook designed to obtain Azure Subscription information.
Step 1 – Create a Graphical Runbook
In this step, we will create a new graphical runbook.
- Login to your SQL Server machine.
- Sign in to Operations Management Suite Portal at http://www.microsoft.com/en-us/server-cloud/operations-management-suite/overview.aspx
- Click the Automation
- Click Create a Runbook. Microsoft Azure Portal will open.
- On the Dashboard, click AzureOMSAutomation.
- Under Resources, click
- In the Azure Portal, in the Runbooks blade, click +Add a runbook.
- Select Create a new runbook.
- In the Name, type Get-CurrentAzureSubscription.
- From the Runbook type drop-down menu, select Graphical.
- Click Create.
Step 2 – Add Activities to a Graphical Runbook
In this step, we will use Library controls to add activities to the runbook.
- In the Azure Portal, in the Runbooks blade, click on Get-CurrentAzureSubscription
- In the Get-CurrentAzureSubscription blade, click on Edit.
- In the Library control, expand Cmdlets | PowerShell.Utility.
- Scroll down to the bottom of the list, right-click Write-Output, and click Add to canvas.
- Click on the Write-Output activity on the canvas. This opens the Configuration control which allows you to configure the activity.
- Change the label to Welcome to OMS UI Runbook.
- Click Parameters to provide values for the cmdlet’s parameters.
- Select the InputObject This is the parameter where we will specify the text to send to the output stream.
- In the Data source dropdown, select PowerShell expression.
- In the Expression box, type “Welcome to OMS UI Runbook” (including the double quotes) and then click OK twice to return to the canvas.
- Save the runbook by clicking Save.
- Click Test pane.
- Click Start.
- When the runbook job completes, its output is displayed. In this case, you should see Welcome to OMS UI Runbook.
- Close Test
- In the Edit Graphical Runbook Get-CurrentAzureSubscription blade, click Publish.
- In the Get-CurrentAzureSubscription blade, click Start and click Yes.
- Once the runbook status shows Completed, click Output. The Output pane is opened, and you can see Welcome to OMS UI Runbook.
- Close the Output
- Click All Logs to open the Streams pane for the runbook job. You should only see Hello World in the output stream, but this can show other streams for a runbook job such as Verbose and Error if the runbook writes to them.
- Close the Streams pane and the Job pane to return to the Get-CurrentAzureSubscription
- Click Jobs to open the Jobs pane for this runbook. This lists all of the jobs status created by this runbook. You can click on any job to open it. This allows you to go back in time and view the details of any job that was created for a particular runbook.
- Close the Jobs
Step 3 – Add Authentication to Manage Azure resources
In this step, we will use the Add-AzureAccount cmdlet to allow the runbook to authenticate in order to manage Azure resources.
- In the Azure Portal, in the Runbooks blade, click on Get-CurrentAzureSubscription
- In the Get-CurrentAzureSubscription blade, click on Edit.
- Right-click on Welcome to OMS UI Runbook and select Delete.
- In the Library control, expand Cmdlets | Azure.
- Right-click Add-AzureAccount and click Add to canvas.
- Select Add-AzureAccount.
- In the Configuration pane, click Configure Parameters. Add-AzureAccount has multiple parameter sets, so you need to select one before you can provide parameter values.
- Click Choose a Parameter set and select the User parameter set. Once you select the parameter set, the parameters are displayed in the Activity Parameter Configuration pane.
- Under Parameter set, click Credential.
- From the Data source drop-down menu, select Credential asset.
- Select Credential asset and click the OMS Account you created earlier in Part I.
- Click OK twice to return to the canvas.
- Click Save.
Step 4 – Add Activity to Graphical Runbook
In this step, you will add a Get-AzureSubscription activity to your Runbook.
- In the Azure Portal, in the Runbooks blade, click on Get-CurrentAzureSubscription
- In the Get-CurrentAzureSubscription blade, click on Edit.
- Under Cmdlets | Azure, right-click Get-AzureSubscription and click Add to canvas.
- Click and drag Get-AzureSubscription underneath Add-AzureAccount.
- Hover over Add-AzureAccount until a circle appears on the bottom of the shape.
- Click the circle and drag the arrow to Get-AzureSubscription. The arrow that you just created is a link. The runbook will start with Add-AzureAccount and then run Get-AzureSubscription.
- Click Get-AzureSubscription and click Configure Parameters.
- Click Choose a Parameter set and click ByName.
- Select SUBSCRIPTIONNAME.
- From the Data source drop-down menu, select Credential asset and click the OMS Account you created earlier in Part I.
- Click OK twice to return to the canvas.
- Click Save.
Step 5 – Finalize Your Graphical Runbook
In this step, we will test, run and publish the graphical runbook.
- In the Azure Portal, in the Runbooks blade, click on Get-CurrentAzureSubscription
- In the Get-CurrentAzureSubscription blade, click on Edit.
- Click Test pane.
- Click Start.
Note: The job will run with the following expected error. The error is produced because you are using a Microsoft account during this clinic. Credential asset can only be used with an Organizational account.
- Close the Test pane to return to the canvas.
- Close the Edit In production environment, you would edit the runbook to use your organizational account credentials, re-test the runbook, and then publish it.
Conclusion
Congratulations! In Part 3 we covered the introduction to OMS Runbooks, we created a Runbook from scratch, then we imported a ready-made runbook from Azure gallery and finally we tested it and published it.
In the second section of this walkthrough article, we created a graphical-style runbook using a graphical tool and a graphical programming model, with little or no code required. It’s a simple insert activity from the library to the canvas, where you can link them together into a workflow, and configure the properties in order to create useful runbooks that automate your IT processes. If you are familiar with System Center Orchestrator, you will be familiar with this intuitive method of creating visual runbooks as well.
Until then… see you in the final part – Part 4.
Thanks for reading!