Introduction

„Azure Automation delivers a cloud-based automation and configuration service that provides consistent management across your Azure and non-Azure environments.It consists of process automation, update management, and configuration features.Azure Automation provides complete control during deployment, operations, and decommissioning of workloads and resources.„

Apart from this gibberish, I will point out some important issues…

Know your Automation

It has something that is called „a feature” – Fair Share – which basically prevent you from running scripts longer than 3 hours.

Well, at least it will pause your script after 3 hours. And if you didn’t implement it as a workflow with some checkpoints – it will RESTART your script from the beginning.

And if you implement checkpoints, it will resume your script from last known checkpoint. BUT it will do this only 3 times! So you are not able to implement logic that takes more than 9 hours to process…

The workaround is to connect your own machine (server or laptop) as a hybrid worker.

We will use quick create, so select „Create a new runbook„, then name it and select type as „PowerShell„.

Use the script below in „Edit” mode, then save it and publish.

PowerShell script

Parameters

It has two parameters:

PipelineName – the name of the pipeline to run

CheckLoopTime – a number of seconds between checking status of a trigerred pipeline run

Invoke-AzureRmDataFactoryV2Pipeline is a cmdlet which I use to trigger a pipeline. Unfortunately, it is an asynchronous operation, so after triggering, we have to periodically check for running state and status.

This script will do it in a simple loop and there will be some wait logic before every iteration. You can parametrize the number of seconds. Every loop also prints out last known pipeline status and timestamp of that check.