As an IT professional, you may have faced the struggle of starting to author a script with a blank page in front of you. After looking at your editor for a few minutes, you may have searched online for examples of what you want to do and then downloaded and modified the examples you found. To make this process more seamless and help you get started, you can take advantage of automation capabilities in Microsoft Operations Management Suite (OMS). You can read more about IT Automation in OMS in general in our earlier blog post. Today, we’re going to look at the Automation Community Gallery in OMS and how you can take advantage of community runbook and module content from within the Automation experience in the Azure portal.
The community gallery in Automation provides a centralized location for building blocks that you need to create your automated processes, and helps streamline the runbook and DSC configuration authoring process. You can now easily find runbooks and PowerShell modules in the Automation Community Gallery. For example, if you want to create and schedule a runbook that installs updates on Linux VMs you can browse the gallery to see if anyone has already created content that performs this task. In this post, we’ll walk you through how you can use the gallery to get started with this task.
Runbooks in the Gallery
You can browse the Runbook Community Gallery to see if there are any scripts that already exist and do something similar to what you need.
To find runbooks in the Azure Portal, go to Browse > Automation Accounts > Runbooks > select Browse Gallery.
Once you are in the community runbook list, you can search the name, description, tag or author to find the runbook you are looking for. Since you’re looking for a runbook that manages Linux, you can search “Linux” to see what turns up.
You can see in the search results that there are a variety of scripts that have the term “Linux” in the description. Since you want to run commands on a Linux machine, you need to select the “Run SSH Command to Install Updates” runbook since that looks like something that you can use. You could also click on the “Filter” command and search for a specific type of runbook or filter out content that is not from Microsoft.
You can click to select this runbook and then read the description, preview the code, and go back to the runbook source on TechNet Script Center to make sure that the runbook is exactly what you’re looking for.
Looking at the script preview, you see that the runbook is the one that you want, but that it also requires an SSH module and connection asset that you will need to set up for the runbook to run successfully. You can continue to import the runbook and then set up the requirements after by clicking the “Import” button and clicking “OK.”
PowerShell Modules in the Gallery
Now that you have the runbook imported, you can navigate to the Automation Module Gallery or go to PowerShell Gallery to deploy the module you want. Below you can see how to find modules using the Automation Module Gallery.
Navigate to your Automation account and select Assets > Modules > Browse Gallery.
You can then search for any of the keywords that you saw in the runbook. For example, you could look for SSH (name), Invoke-SSHCommand (command in module), JoeLevy (author) and any of these keywords will return the module that you are looking for.
You can then drill into the module and import it to your Automation account. Since the SSH module doesn’t have any dependencies, you can click the import button to import to your account. If there were required dependencies, you would be asked to import them before continuing.
Automation will then extract the activities and import an asset Connection Type if the module has a Connection Type defined in it. In this case, the SSH module does have an Automation connection. You can learn about Connection assets in Azure Automation and refer to this blog post that talks about how to author PowerShell modules with a connection type defined: Authoring Integration Modules for Azure Automation.
Module is ready for use:
Now that the module has finished extracting, you can go to Assets > Connections. Since the module contained connection type “SSH,” you can create a connection to your Linux machine that will be used in the runbook you imported.
Conclusion and resources
With all the requirements setup in your account, you’re ready to test the runbook. If you open the runbook and put it in edit mode, you can test the runbook and view the output. The screenshot below shows the runbook successfully running and outputting the list of updates you need to install on your Azure Ubuntu VM, and then the updates that were installed.
As you can see, the Automation Gallery for runbooks and modules has simplified the process of finding and importing existing content to your account and getting a solution working.
Learn more about runbook and module galleries for Azure Automation.
Want to contribute to the community?
Any PowerShell script, PowerShell Workflow, or Graphical runbooks that you publish to Script Center under the Azure category will be loaded to the Azure Automation Gallery. Read our documentation for more information on contributing runbook content.
All modules shared on PowerShell Gallery will also appear in the Automation Module Gallery.
Have solutions that you want to see, features that you want added, or to provide feedback on existing features? Request them on Azure Automation UserVoice.