Application Monitoring and Alerting
Platform Monitoring and Alerting
The course is part of these learning pathsSee 3 more
In this lesson, you will learn about automation in Azure. We will cover the three basic categories: Azure web console tools, PowerShell scripts with Azure SDK, and third-party tools like Chef.
We will start by focusing on Azure’s built-in tool set:
- Runbooks: a collection of scripts used by the Azure SDK API to execute changes to your Azure system
- Configurations: special methods within PowerShell that let you predefine a configuration state for your servers
We will discuss Azure Event Grid, its interactions with both Azure and non-Azure services, and some of the configurations available. We will walk you through how to create an Event Grid subscription.
Finally, you will learn about several non-Azure tools such as Chef and Puppet. You will see how they differ from Azure by using cookbooks, recipes, manifests, and modules.
When it comes to automation with Azure we have a lot of different options. The three basic categories are Azure web console tools, PowerShell scripts with Azure SDK, or a third party tool like Chef. Which approach we take will be a function of our expertise and the nature of the work we want to automate.
We will start by focusing on Azure’s built-in tool set. Azure Automation is comprised of two core pieces: Runbooks and Configurations, both built on top of PowerShell. Before you do anything you will need to set up an Azure Automation account in the UI. Once done you are ready to start writing PowerShell runbooks and PowerShell Desired State Configurations (DSC). A runbook is a simply a collection of scripts. These scripts use the Azure SDK API to execute changes to your Azure system. It takes some programming knowledge to use it properly. The upside is that Powershell is far more flexible than simply using the web gui.
Desired State Configurations are special methods within PowerShell that let you predefine a configuration state for your servers. For example you can enforce that specific ports are open or that only a specific set of software is installed. DSC greatly simplifies the process of writing scripts by letting you work from the end state. The Azure documentation and console make it very easy for non-programmers to generate and import basic PowerShell DSC scripts in their Azure Automation account. It lets you define a specific end state for your Azure systems and let Azure do the work of getting things there. Be warned that DSC Configurations sometimes do tasks in a manner or order you don’t expect. If you have very delicate requirements regarding how and when things change in your system it may be better to write more explicit PowerShell code instead of relying on DSC.
Azure also has a service for intelligent event routing. It is called Azure Event Grid and it lets you automate responses to relevant events across both Azure and non-Azure services. Event Grid uses a publish-subscribe model and is configurable in the portal or by using Azure CLI or Powershell scripts. To use Event Grid you need to create an event subscription. This is done by selecting ‘Add Event Grid subscription’ to the relevant app in the Azure portal. The Azure documentation includes a number of handy examples of how you can make use of this. In one it shows how you can use Event Grid to automatically resize images uploaded to your Azure storage. It can be done in minutes and save you a great deal of time and money that would be spent on manually fixing images.
Let’s turn our attention to some non-Azure tools. Chef and Puppet are two cloud infrastructure automation tools. Both have open source offerings that have integrations with not only Azure, but other providers like Google Cloud and AWS. Chef and Puppet have different names for their different pieces. For example in Chef, modules are described as ‘cookbooks’ with scripts called ‘recipes.’ In Puppet these things are called ‘manifests’ and ‘modules.’ One thing to note is that both are fairly complex tools. If your automation needs are very simple, then it is likely not a great idea to try to set up Chef or Puppet; better to just stick with Azure’s built-in tools such as PowerShell with DSC or Event Grid.
So we he have discussed Chef, Puppet, Powershell with DSC, Runbooks, and Event Grid. As you can see, we have a lot of options when it comes to automating work in Azure. In our next lesson we will focus in on a specific use case: autoscaling. Let’s get started.
About the Author
Jonathan Bethune is a senior technical consultant working with several companies including TopTal, BCG, and Instaclustr. He is an experienced devops specialist, data engineer, and software developer. Jonathan has spent years mastering the art of system automation with a variety of different cloud providers and tools. Before he became an engineer, Jonathan was a musician and teacher in New York City. Jonathan is based in Tokyo where he continues to work in technology and write for various publications in his free time.