{"id":14073,"date":"2022-09-01T09:25:52","date_gmt":"2022-09-01T09:25:52","guid":{"rendered":"https:\/\/blog.cloudthat.com\/?p=14073"},"modified":"2024-06-25T10:54:42","modified_gmt":"2024-06-25T10:54:42","slug":"an-introduction-to-azure-automation-account-with-a-usecase-for-runbook","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/an-introduction-to-azure-automation-account-with-a-usecase-for-runbook","title":{"rendered":"An Introduction to Azure Automation Account with a Usecase for Runbook"},"content":{"rendered":"<table border=\"0\">\n<tbody>\n<tr>\n<td>\n<h2><span style=\"color: #000080;\"><strong>TABLE OF CONTENT<\/strong><\/span><\/h2>\n<\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#introduction\">1. Introduction<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#prerequisites\">2. Prerequisites<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#processautomation\">3. Process Automation<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#types\">4. Types of Runbooks<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#usecase\">5. Azure Usecase for Runbook<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#conclusion\">6. Conclusion<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#aboutcloudthat\">7. About CloudThat<\/a><\/td>\n<\/tr>\n<tr>\n<td><a style=\"margin-left: 20px;\" href=\"#faqs\">8. FAQs<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h2 id=\"introduction\"><strong><span style=\"color: #000080;\">Introduction<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\">Automating repetitive tasks can make the job easier and reduce manual errors. The Azure Automation Account helps you to orchestrate complex and repetitive operations that can be used for both Azure and Non-Azure environments. Azure Automation manages your infrastructure and applications throughout the lifecycle. Here in this blog, we are going to look more deeply into this service provided by Azure. We will also execute Runbooks in the Automation account for two use cases.<\/span><\/p>\n<h2 id=\"prerequisites\"><strong><span style=\"color: #000080;\">Prerequisites<\/span><\/strong><\/h2>\n<ul>\n<li><span style=\"color: #000000;\">Azure Automation account<\/span><\/li>\n<li><span style=\"color: #000000;\">Resource groups<\/span><\/li>\n<\/ul>\n<h2 id=\"processautomation\"><strong><span style=\"color: #000080;\">Process Automation<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\">It orchestrates processes using graphical, PowerShell &amp; Python Runbooks. Runbooks are the scripts hosted in Azure Automation. Different triggers like Schedule and Webhook can launch these Runbooks; Azure alerts, Logic apps, PowerShell &amp; Watcher Tasks, which gives the user a lot of flexibility in creating custom automation. When the Runbook is ready, you can send it for automation, and Azure assigns a worker to run each job during Runbook execution. The point to note here is that Azure Automation itself manages the worker created by Azure for this task. They are called Azure Sandbox. Hybrid Runbook Worker can also execute Runbooks directly on the computer that hosts the role and against local resources in the environment.<\/span><\/p>\n<h2 id=\"types\"><strong><span style=\"color: #000080;\">Type of Runbooks<\/span><\/strong><\/h2>\n<ul>\n<li><span style=\"color: #000000;\"><strong>PowerShell runbooks<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>PowerShell Workflow runbooks<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>Graphical runbooks<\/strong><\/span><\/li>\n<li><span style=\"color: #000000;\"><strong>Python Runbooks<\/strong><\/span><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">Here we will see a use case for the PowerShell Workflow runbook.<\/span><\/p>\n<h2 id=\"usecase\"><strong><span style=\"color: #000080;\">Azure Usecase for Runbook<\/span><\/strong><\/h2>\n<h3><span style=\"color: #000000;\">a) Automation account creation<\/span><\/h3>\n<p><span style=\"color: #000000;\">Log into the Azure console and go to the Automation account<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14080\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook1.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"205\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">Give the Automation account a name and choose a Resource group as well.<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14081\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook2.png\" alt=\"Azure Runbooks\" width=\"504\" height=\"379\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">Once it is created, do select Azure Run as an account on the Run as account option under the Account settings.<\/span><\/p>\n<p><span style=\"color: #000000;\">Runbooks will get executed if and only if this permission is added.<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14082\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook3.png\" alt=\"Azure Runbooks\" width=\"845\" height=\"359\" \/><\/a><\/p>\n<h3><span style=\"color: #000000;\">b) Implementing PowerShell Workflow for deleting empty Resource Groups<\/span><\/h3>\n<p><span style=\"color: #000000;\">Once this Runbook is executed Azure Automation deletes the resource group which has no resources attached to it.<\/span><\/p>\n<p><span style=\"color: #000000;\">Under Process Automation select Runbooks and choose to Create a runbook<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14083\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook4.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"234\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">Provide a runbook name and runbook type as PowerShell Workflow. Also, ensure the Runbook name matches the name of the source code file.<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14084\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook5.png\" alt=\"Azure Runbooks\" width=\"534\" height=\"409\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">Insert the code from the given <a href=\"https:\/\/github.com\/mouliswaran\/Automationblog.git\" target=\"_blank\" rel=\"noopener\"><strong>GitHub link<\/strong> <\/a>and save it. Select the Test pane to test it on Azure.<\/span><\/p>\n<p><span style=\"color: #000000;\">Select Start to execute the imported runbook<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14085\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook6.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"250\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">These are the below resource groups on my account before the runbook execution<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14086\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook7.png\" alt=\"Azure Runbooks\" width=\"769\" height=\"235\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">After execution, you can see the output below:\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14087\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook8.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"335\" \/><\/a><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14088\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook9.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"207\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">Next, we will go back to the code and choose to publish<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14089\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook10.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"252\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">Once you publish your Runbook, we can be able to start it straight away, or we can schedule it, or we can add Webhook.<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14090\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook11.png\" alt=\"Azure Runbooks\" width=\"796\" height=\"178\" \/><\/a><\/p>\n<p><span style=\"color: #000000;\">After publishing your Runbook, whenever the Runbook gets executed, the logs and output are stored in the Jobs section under Process Automation.<\/span><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14091\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook12.png\" alt=\"Azure Runbooks\" width=\"638\" height=\"330\" \/><\/a><\/p>\n<p><a href=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14092\" src=\"https:\/\/d1f7lmxeo98xps.cloudfront.net\/resources\/wp-content\/uploads\/2022\/11\/runbook13.png\" alt=\"Azure Runbooks\" width=\"758\" height=\"358\" \/><\/a><\/p>\n<h2 id=\"conclusion\"><strong><span style=\"color: #000080;\">Conclusion<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\">This blog has seen various types of Runbooks and a use case for PowerShell Workflow runbook. Likewise, you can use this to integrate with Azure alerts, Azure Site Recovery, VM Patching, and other third-party systems for managing your processes. Azure Automation may look simple but it is a very powerful service for both processes automation and daily operations. I am ending this blog with this statement, &#8220;Azure Automation has optimized the overall operational processes, thus, increasing the overall performance significantly.&#8221;<\/span><\/p>\n<h2 id=\"aboutcloudthat\"><strong><span style=\"color: #000080;\">About CloudThat<\/span><\/strong><\/h2>\n<p><a href=\"https:\/\/www.cloudthat.com\/\" target=\"_blank\" rel=\"noopener\"><strong>CloudThat<\/strong><\/a>\u00a0<span style=\"color: #000000;\">is\u00a0the official AWS (Amazon Web Services) Advanced Consulting Partner, Microsoft Gold Partner, Google Cloud Partner, and Training Partner helping people develop knowledge of the cloud and help their businesses aim for higher goals using best-in-industry cloud computing practices and expertise. We are on a mission to build\u00a0a robust\u00a0cloud computing ecosystem by disseminating\u00a0knowledge on technological intricacies within the cloud space.<\/span><span class=\"TextRun BCX0 SCXP93070984\" lang=\"EN-IN\" xml:lang=\"EN-IN\"><span class=\"NormalTextRun BCX0 SCXP93070984\"><span class=\"TextRun BCX0 SCXP59000031\" lang=\"EN-IN\" style=\"color: #000000;\" xml:lang=\"EN-IN\"><span class=\"NormalTextRun BCX0 SCXP59000031\">\u00a0<\/span><\/span><span class=\"TextRun BCX0 SCXP59000031\" lang=\"EN-IN\" xml:lang=\"EN-IN\"><span class=\"NormalTextRun BCX0 SCXP59000031\"><span class=\"EOP SCXP258354852 BCX0\"><span class=\"EOP SCXP66056781 BCX0\"><span class=\"EOP SCXP242272637 BCX0\"><span class=\"TextRun SCXP239778695 BCX0\" lang=\"EN-IN\" xml:lang=\"EN-IN\"><span class=\"NormalTextRun SCXP239778695 BCX0\"><span style=\"color: #000000;\">Explore our<\/span>\u00a0<strong><a href=\"https:\/\/www.cloudthat.com\/consulting\/\" target=\"_blank\" rel=\"noopener\">consulting here<\/a>.<\/strong><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p><span style=\"color: #000000;\">If you have any queries regarding Automation, Azure Automation Account, or Runbooks, drop a line below the comments section. I will get back to you at the earliest.<\/span><\/p>\n<h2 id=\"faqs\"><strong><span style=\"color: #000080;\">FAQs<\/span><\/strong><\/h2>\n<h4><strong><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">1.) How can we manage pathing using Runbook?<\/span><\/span><\/strong><\/h4>\n<p><span style=\"color: #000000;\">\u00a0Azure Automation Update Management does use the System Hybrid Runbook Worker, and the installation of Update\/patch is done through Runbooks. It can also be used to manage OS updates for physical machines\/VMs in on-premises environments and in other cloud environments<\/span><\/p>\n<h4><strong><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">2.) What is a Watcher task?<\/span><\/span><\/strong><\/h4>\n<p><span style=\"color: #000000;\">\u00a0A watcher task allows you to watch for events and trigger actions. It is comprised of a watcher runbook and an action runbook. The watcher searches for an event and triggers the action when an event occurs. For example, you can watch a folder for new files and trigger an action that backs up those files when they are created.<\/span><\/p>\n<h4><strong><span style=\"text-decoration: underline;\"><span style=\"color: #000000; text-decoration: underline;\">3.) What is a Hybrid Runbook Worker?<\/span><\/span><\/strong><\/h4>\n<p><span style=\"color: #000000;\">\u00a0A Hybrid Runbook Worker is a server that resides locally inside your on-premises data center, in AWS or in Azure, or can exist virtually anywhere in the world. It gives you the capability to hybrid manage your complete infrastructure. You can automate tasks against your infrastructure leveraging Azure Hybrid worked capabilities provided by Azure Automation.<\/span><\/p>\n","protected":false},"author":219,"featured_media":14326,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3608,3607],"user_email":"prarthitm@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/14073"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/219"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=14073"}],"version-history":[{"count":2,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/14073\/revisions"}],"predecessor-version":[{"id":45654,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/14073\/revisions\/45654"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=14073"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=14073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}