-
Author a runbook
To author a runbook, you can develop new Windows PowerShell runbooks on your own and enter your own Windows PowerShell commands. You can call common global runbooks that you have in your asset library. You can then access those runbooks as linked libraries. For instance, you could have a runbook that manages all your credentials and connections that you call from each runbook at the start. A best practice when authoring runbooks is to write granular and single tasks so you can then reuse and insert them later (after they are published) in other runbooks.
All the authoring can be done in the browser in the Azure Management Portal. Log in to the Azure Management Portal, click Automation, and on the Automation page, click the Azure Automation account of interest. On the Automation account’s page, click Runbooks, and then click the name of the runbook. On the runbook’s page, click Author. At the bottom of the screen, click Edit to allow you to enter or modify its content right there in the Azure Management Portal. This puts the runbook automatically into draft mode for the version you are editing. Note that the previous published version still exists as a separate entity while the editing is taking place.
On the Author tab within Edit mode, you can take the following actions.
- Manage From here, you can select the following options:
- Import Module After a module is imported, you can call activities (cmdlets) from that module in your runbook.
- Add Setting This allows you to create any type of asset, or add a type of asset or setting to the runbook code. You insert a setting (or asset) with set or get operations on the assets. These assets have global scope to the entire account for all runbooks in that Automation account.
- Insert From here, you can select the following options:
- Activity In this context, an activity is a cmdlet. An integration module is a package that contains a Windows PowerShell module; you can import it into Azure Automation. You choose the integration module, and then select the activity, for example, Add-AzureAccount. After selecting the activity, click the arrow to go to the activity’s Parameters page where you can make selections from the Parameter Set drop-down list box for required and optional parameters. Select the check mark to close the Insert Activity dialog box and return to the runbook where the template for the activity has been inserted.
- Runbook Select this option to insert an entire runbook from the list of published runbooks in your Azure account. Call the newly inserted runbook just like you would an Azure cmdlet, passing in parameters and getting values back.
- Setting Choose a setting action in which you can get or set a variable, get a connection, get a certificate, and get a Windows PowerShell credential.
- You can create an asset that is a global entity. If the asset is created by one runbook, it can be called by another asset in the same Azure Automation account.
- Save After you have finished entering or inserting the script into your runbook, click Save. If you decide you don’t want to keep the modifications, you can leave the page via the browser controls, or by clicking on another runbook or another tab.
- Discard Draft This option only applies if the Authoring column of the runbook shows a status of In Edit. As mentioned previously, you can have both a published and a draft version of a runbook. If you want to get rid of the draft version of the runbook, click Discard Draft.
- Test Select this option to run the draft workbook, which will modify any Azure resources as if the runbook was running in published mode.
- Publish Select this option after you’re satisfied that your runbook works as it should. Publish promotes the runbook to a published status. When placed into published status, a runbook is in read-only mode and cannot be edited unless it’s transitioned back to draft status.
A common point of confusion about authoring of runbooks concerns simultaneous editing by more than one user from different instances of the portal, for example, a co-administrator scenario. In the Azure Management Portal, you can have more than one administrator, so at times two or more administrators could author a runbook at the same time. However, be aware that Azure does not lock a runbook for editing by a single user. In the Azure Management Portal, a runbook that is being edited is shown as In Edit status. No information is provided about how many people might be editing the runbook.
As a general guideline, if a runbook is in in edit status, no one but the initial person editing the runbook should edit it until it leaves this state. It’s best to wait until the runbook is moved out of in edit status and the draft status has moved into a published state before you try to make changes to it. You can also contact your co-administrator who is editing the runbook and get a copy of the runbook. Then, you can add your changes to their latest edited version.
Source of Information : Azure Automation
Subscribe to:
Post Comments (Atom)
0 comments: