How to start a Runbook on specific Hybrid Worker Azure Automation

Automation is the next big thing in IT. There are various automation tools that can be used to create a runbook for hybrid workers on Azure Automation, but what does it take to start one? We’ll walk you through the steps of designing and building your own successful automated process solution.

The “azure automation hybrid worker modules” is a new feature that was released with the release of Azure Automation. This feature allows you to start a Runbook on specific Hybrid Worker Azure Automation.

How to start a Runbook on specific Hybrid Worker Azure Automation

Please note that this is a workaround that is not always effective.

I’ve recently started working with a customer that has one Hybrid Worker Group (and to whom we are not allowed to make any adjustments).

There are runbooks that must work with data from other runbooks, but since the data is so large and is edited by a different team, they decided to produce the data first and then modify it in segments over the course of four days.

This guarantees that we now have two schedules, one for Runbook1 and the other for Runbook2, the latter of which begins four days in a row and converts the data.

The drawback is that the data is saved on a Hybrid Worker, and the second schedule begins on a different Hybrid Worker. Why don’t you have a file share, you could think? Regrettably, this is not achievable inside the ecosystems.

We are typically creative because we are subjected to a variety of constraints. As a result, I devised the following function, which is detailed in the next paragraph.


But what exactly do I mean when I say “disclaimer”?

The function basically restarts the Runbook until it runs on the proper Hybrid Worker.

With two to five Hybrid Workers, this is still doable. The issue is whether you want to do it that way if you have more than five. The likelihood of selecting the proper Hybrid Worker decreases as the number of Hybrid Workers increases.

Perhaps you should focus on a single Hybrid Worker Group with a single Hybrid Worker on which these sorts of runbooks can run.


Let’s establish a runbook in Azure Automation for a particular Hybrid Worker.

So, in a nutshell, how does the function work?

When the runbook on the Hybrid Worker you choose is not running. It will restart the runbook and sleep for the amount of time specified in the StartSleep argument. Because the Runbook is still in sleep mode, a Hybrid Worker with higher performance capacity will be used. When the timer expires, the runbook will be terminated with the statement Exit.

Keep in mind that if the Hybrid Worker name is wrong, it might cause an endless cycle! Pay close attention to the Hybrid Worker parameter.


Github is where you can get the function.

Before you use this function, make sure you understand the HybridWorker argument.

A Github repository is used to store the function. You may use Azure automation to replicate the function from Github.

You can then use the following code to dot source the method into your Runbook:

Start-SpecificHybridWorker.ps1 is a script that starts a specific hybrid worker.

And just call the function by its name (not the name of the runbook):

Start-SpecificHybridWorker – Starts a specific hybrid worker (including parameters)


Let’s have a look at the function.

There are four arguments to the function:

  • Runbook
  • HybridWorkerGroup
  • HybridWorker
  • StartSleep

Book of Runs (mandatory)

This is a required parameter, but it’s a simple one.

This is the Azure Automation runbook you wish to start with. You don’t need to include a.ps1 extension after the name.

I’ll use the following as examples:

Start-SpecificHybridWorker.ps1 is a script that starts a specific hybrid worker. Start-SpecificHybridWorker -Runbook ‘Runbook1’


HybridWorkerGroup is a group of hybrid workers (mandatory)

This parameter is required.

This is the HybridWorkerGroup that includes the Hybrid Worker in question. In the Azure site, you can see the names of the groups and which Hybrid Workers are a member of them.

Search for and open Hybrid Worker Groups in the suitable Azure Automation environment.

In Azure Automation, how can I start a runbook on a fixed Hybrid Worker?In Azure Automation, how can I start a runbook on a fixed Hybrid Worker?

Hybrid Workers are found under User Hybrid Worker Groups on the right-hand tab.

These are the Hybrid Workers on which a runbook may be used.

In Azure Automation, how do I execute a PowerShell script on an assigned Hybrid Worker in a Hybrid Worker Group? In Azure Automation, how do I execute a PowerShell script on an assigned Hybrid Worker in a Hybrid Worker Group?

As a result, the parameter expects the Group Name rather than the Hybrid Worker. ‘Test’ is the name of my group.

As a result, the cmdlet now appears as follows:

Start-SpecificHybridWorker.ps1 is a script that starts a specific hybrid worker. Start-SpecificHybridWorker -Runbook ‘Runbook1’ -HybridWorkerGroup ‘Test’


HybridWorker

This argument isn’t required! Isn’t it strange? No, not at all.

When you DO add a name, keep the following in mind:

Remember that if you type in the incorrect name, you’ll end up in an endless cycle. As a result, ensure sure the name is right and that you update it manually when the server is phased out.

The name is identical to the name returned by $env:COMPUTERNAME. If we use my laptop as an example, it would seem as follows:

DESKTOP-1SDR953 $env:COMPUTERNAME

As a result, the cmdlet would be:

Start-SpecificHybridWorker.ps1 is a script that starts a specific hybrid worker. Start-SpecificHybridWorker -Runbook ‘Runbook1’ -HybridWorkerGroup ‘Test’ -HybridWorker ‘DESKTOP-1SDR953’

When you don’t want to add a name:

If you don’t provide the function a name, it will just grab the first Hybrid Worker in the Hybrid Worker Group.

If you don’t utilize the HybridWorker argument, the function will need some additional Azure Automation functionality. In Azure Automation, we’ll need an additional function and three variables.

The method New-ManagedIdentityAccessToken is required. This is also available on Github.

Install it in Azure Automation similarly to the Start-SpecificHybridWorker function.

It’s not necessary to dot source it. The function does this for you automatically.

Three new Azure Automation Variables are also required. Strings are all of them.

  • AzureSubscription This is the identifier for your AzureSubscriptionId.
  • ResourceGroupName The AutomationAccount is included in the ResourceGroupName.
  • AzureAutomationAccount The AutomationAccountName is the name of the automation account.

To add variables, you may use the Microsoft Docs.


StartSleep

I use the Start-Sleep cmdlet to start a runbook on another Hybrid Worker.

Otherwise, since the Runbook alternates between Hybrid Worker 1 and 2, I’m concerned the wrong Hybrid Worker may be picked.

30 seconds is the default setting. If you have more than two Hybrid Workers, I’d recommend increasing this to at least 60 seconds.

The cmdlet would be: by modifying StartSleep: by customizing StartSleep: by tweaking StartSleep: by customizing

Start-SpecificHybridWorker.ps1 is a script that starts a specific hybrid worker. Start-SpecificHybridWorker -Runbook ‘Runbook1’ -HybridWorkerGroup ‘Test’ -HybridWorker ‘DESKTOP-1SDR953’ -StartSleep 60

After the timer has finished, the function exits the runbook.


A real-life Start-SpecificHybridWorker example

The scripts that go into sleep mode for 60 seconds are still in sleep mode in the image below, and the right Hybrid Worker is only utilized on the third attempt.

How to launch a Runbook on a particular Azure Automation Hybrid WorkerHow to launch a Runbook on a particular Azure Automation Hybrid Worker

Related

Watch This Video-

The “azure automation runbook limitations” is a limitation on the number of concurrent tasks that can be started using Azure Automation. There are some workarounds to this problem.

Frequently Asked Questions

How do you trigger a runbook?

A: You have to either manually trigger it or use the Run button.

How do I create a hybrid runbook in Azure?

A:
We dont have a hybrid runbook in Azure.

What is hybrid runbook worker in Azure?

A: Hybrid Runbook Worker is a new type of runbook worker that combines the Azure Automation Engine with Azure Functions.

Related Tags

  • please remove the hybrid workers from the group before performing this operation
  • azure automation runbook examples
  • azure automation hybrid worker pricing
  • hybrid runbook worker active directory
  • azure automation on premise active directory