• Ash K.

Use Azure Automation to Eliminate Clunky Scheduled Tasks

Do you dream of being completely cloud based, but you're still reliant on Scheduled Tasks for your custom automation? If you're tasked with reducing your on-prem footprint, you know that it can be a difficult journey to find a solution for your custom Powershell integrations and automations. Enter: Azure Automation.


You can use an Azure Automation account and Powershell runbooks to replace all of your O365, Azure, and Web automations that currently run as Scheduled Tasks in your on-prem infrastructure.

To use Azure Automation, you'll need an Azure Subscription. Azure Automations and Automation Accounts are billed based on usage; you can find more info on that here.


Watch the videos or follow the steps below to create and configure a recurring Azure Automation. At the end of the article, I provide you with some easy Powershell audits designed to be plug-and-play with Azure Automation. You can find them on my GitHub.


Creating an Azure Automation Account, Adding Modules, and Creating a PS Runbook

Creating Schedules and Linking Schedules to Your PS Runbook


Creating an Azure Automation Account

1. Sign into www.portal.azure.com

2. Navigate to Automation Accounts

3. If you have multiple subscriptions, choose the right one and then select "+Add"

4. In the "Add Automation Account" blade, enter a name, select the subscription and resource group, and select "Create"

5. Wait for Azure to provision the resource, and then select "Go to Resource" from the notification in the upper right

6. Success! Your Automation Account has been created!


Installing Modules for PS Runbooks

1. Under "Shared Resources", select "Modules gallery"

2. In the search, type the name of the module you'd like to install and select it from the list

3. From the module blade, select "Import"

4. From the import screen, select "Ok"

5. You can do this multiple times until all of your desired modules are installed

6. Navigate back to the Automation account blade


Creating your PS Runbook

1. From the Azure Automation account blade, under "Process Automation", select "Runbooks"

2. From the Runbooks blade, select "Create a runbook"

3. Give your runbook a name, select Powershell as the type, give it a description, and select "Create"

4. Wait for the runbook to be provisioned

5. To use a module from the installed modules library, make sure to include "Import-Module"

6. Enter your code, and select "Test Pane"

7. In the test blade, select "Play"

8. Success! You created your first runbook!


Scheduling your Recurring PS Runbook

1. From the Azure Automation account blade, under "Shared Resources", select "Schedules".

2. Select "+ Add a schedule"

3. Add a Name, Description, Start Date, and Time Zone, then select "Recurring"

4. You can set recurrences by Hour, Day, Week, or Month; you can also set an expiration. This schedule can be used for multiple runbooks.

5. When you've added your recurrence schedule, select "Create".

6. Go back to the account blade; under "Process Automation", select "Runbooks"

7. Select the runbook you want to schedule

8. From the option bar on the top, select "Link to Schedule" (note: if this option is greyed out, you probably haven't published the runbook yet. Only published runbooks can be scheduled)

9. From the schedule blade, select "Link a schedule to your runbook", and then select your schedule from the list

10. You'll likely have Parameters and Run Settings. Make sure to complete those before scheduling your runbook.

11. Select "Ok" when you're finished

12. Your runbook is now scheduled! Make sure to audit your runbooks for completion and accuracy


Some easy runbook ideas from my GitHub to get you started:

1. Monthly O365 license consumption audit

2. Monthly HaveIBeenPwned user data breach audit

©2019 by KickA5h Admin

All code provided on this website is done so with the confidence that you know never to execute untrusted code in your environment.