Key DataRunbooks and jobs are key objects in Azure Automation that you want to keep track of. Runbooks are the PowerShell Workflows that contain your logic for the automation of important processes, and jobs are the individual runs of your runbooks. Thus, it is no surprise that any report on the system will have a focus on runbooks and their jobs.
General InfoAt the top of the report you will see information that orients you to the scope of the report – the time period, subscription, and Automation account. The time period always ends at the time when the report runbook kicked off; the start time will be one or more whole days prior to that, depending on your configuration. Note that each report is for a single Automation account. If you have more than one account, then to get reports on all of the accounts you will want to import and configure the New-AutomationReport runbook in each account.
Runbooks with JobsOne of the first pieces of information you'll want to know is – Which runbooks have been running? You want to quickly scan a list of the runbooks that had jobs during the time period and see how each job turned out. Because the runbooks contain the logic for your business processes, the name of each runbook (along with your knowledge of the inner workings of each runbook) will inform you about which processes were run and what changes were made in Azure or third-party systems. If one or more jobs have a potentially non-happy status – “failed”, “suspended”, “stopped”, “completed with errors”, or “queued” – then you will see these highlighted as something to investigate. This information is presented in a table with a row for each runbook that has had one or more jobs in the report time period. For each runbook you can see the count of jobs that had a certain status. This table will give you a quick overview of the runbook job health, and allow you quickly to see if there are any jobs that require further investigation.
JobsAfter the quick overview of runbooks with jobs during the reporting period, the report gives you a section that focuses on jobs specifically, with data useful for drilling down into problem jobs that may have occurred. In this section of the report you will first see a summary of the total count of jobs that ran and the count of jobs for each job status. If there are any actionable jobs – jobs with status of “Completed with Errors”, “Failed”, “Queued”, “Stopped”, or “Suspended” – then the report will give details of those jobs in subsections by status. You can use the runbook name and job id within the Azure Automation portal to find the job and drill into the job details to troubleshoot the issue.
Note: The job statuses shown are those present in the database at the time the report was run. Thus, a queued job may have started and completed by the time you look at the report, and a running job may have reached a final state. Both of these would appear in the next report along with their final state.
Modified RunbooksThe final section of the report will let you know about any runbooks that have been modified or whose status has changed in the time period of the report. This includes any “new” runbooks that have been created, any runbooks “published” during the time period, and any “in edit” runbooks that are being modified. If you have a team that works on runbooks in Azure Automation, this can help you keep tabs on which runbooks are being worked on and any runbooks recently published.
Importing and Configuring the New-AutomationReport RunbookYou can import the New-AutomationReport runbook from the Automation gallery into your Automation account. Just click +New in the Azure portal to create a new Automation Runbook. Click to import it From Gallery, and then select New-AutomationReport in the wizard. Once you have the runbook imported, you need to set up a few assets (which can also be useful in many of your other runbooks):
- A credential asset that contains an Azure AD credential with administrative access to the Azure subscription. For more information see this post.
- A variable asset which contains the Azure Subscription name.
- A variable asset which contains the Automation Account name.
- A credential asset that contains the credential for the SMTP service.
Running the Automation Report on a ScheduleYou will probably want to set up a recurring schedule that will kick off this runbook automatically. For example, if you want to check up on your automation daily, then create a daily schedule and link the runbook to it. In the wizard where you link the runbook to a schedule you will need to set the three parameters that the runbook takes for input – NumberOfDaysForReport is an integer that indicates the period of days for the report; OutputHtml is a Boolean that indicates whether to format the report as HTML or as plain text; and SentReportByEmail is a Boolean that indicates if the report should be sent via SMTP or just stored in the job output. The screenshots below illustrate this.