Scripted Actions - Azure Runbooks
Azure Runbooks scripted actions are run via an automation account in Azure. This enables automated actions of Azure resources outside of the VM.
Azure Runbooks Use Case
For some automations, the necessary actions to take must be performed in the context of Azure, outside of the VM itself. While these commands could be run on the VM with the Azure PowerShell module installed, running scripts on session hosts that target Azure are less efficient and can be unreliable. Azure Automation allows for consistent execution, and allows for the Nerdio Manager app to easily run the scripts as itself. Some scripts even require the VM to be restarted or shut down, which means it could not be run on the session VM regardless.
Add an Azure Runbook
Nerdio Manager allows you to add an Azure Runbook.
To add an Azure Runbook:
At the MSP or Account level, navigate to Scripted Actions > Azure runbooks.
Select Add scripted action.
Enter the following information:
Name: Type the name of the script. This name is displayed when you select this action from the list of available scripted actions.
Description: Type the script's description.
Tags: From the drop-down list, select optional tags for the script. These tags are used for searching and organization.
Script Execution Mode: From the drop-down list, select the script's execution mode.
Combined: Marks the script as one that can be combined safely with other scripts. For example, a script that adds a registry value.
Individual: A stand-alone script for an action that should be run on its own. For example, a long script with commonly used variable names that may conflict with other scripts, or a script that requires a fresh PowerShell session.
Script: Type the PowerShell command(s) to execute.
Note: Cmdlets used in this code must be available on the VMs or in the Azure Automation account. If using PowerShell cmdlets from modules not present by default on the Windows VMs or in the Azure Automation account, the modules must first be installed.
Nerdio provides several pre-populated variables that can be used in the script code. The available variables are:
$HostPoolId (Available when the script is associated with a host pool)
$HostPoolName (Available when the script is associated with a host pool)
$AzureSubscriptionId
$AzureSubscriptionName
$AzureResourceGroupName
$AzureRegionName
$AzureVMName (Available when the script is associated with a VM)
$ADUsername (if passing AD credentials)
$ADPassword (if passing AD credentials)
$DesktopUser (Available when the script is associated with a personal host pool)
Tip: It is recommended to develop code using an IDE such as VSCode or ISE. Then test the PowerShell code on a dedicated development session Host /Azure VM.
Once you have entered all the desired information, select OK.
Manage Azure Runbooks
Nerdio Manager allows you to manage existing Azure Runbooks.
To manage a Azure Runbooks:
At the MSP or Account level, navigate to Scripted Actions > Azure runbooks.
Optionally, you can view the status of scripted actions tasks in the Scripted Actions Tasks section.
Optionally, you can search and filter the list of Azure Runbooks.
Locate the Azure Runbook you wish to work with and from the action menu select one of the following actions.
View: You can view the Azure Runbook details.
Edit: You can edit the Azure Runbook.
Clone: You can clone an Azure Runbook scripted action.
Run now: You can run the Azure Runbook scripted action immediately.
Notes:
Select Add to specify parameters or variable names to be passed to the selected scripted action.
Select Show advanced settings to specify AD credentials and execution timeout.
Schedule: You can run the Azure Runbook scripted action as per a schedule.
Assign Accounts: (MSP Level Only) You can assign account(s) to a selected scripted action.
Note: From the drop-down list, select All to assign the scripted action to all accounts.
Delete: (MSP Level Only) You can delete a selected scripted action.
Comments (0 comments)