Skip to content

The helper scripts to utilize the Azure Proactive Resiliency Library (APRL). The scripts allow batch execution of the APRL's queries.

License

Notifications You must be signed in to change notification settings

tksh164/aprl-helper-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APRL helper scripts

The helper scripts to utilize the Azure Proactive Resiliency Library (APRL). The scripts allow batch execution of the APRL's queries and PowerShell scripts.

Helper scripts

Three helper scripts have different purposes.

  • getaprl.ps1: Downloads the APRL contents from the APRL GitHub repository. After downloading, this script extracts Azure Resource Graph (ARG) queries and PowerShell scripts, also stores it into the queries folder in the current directory. The queries folder will be created if it does not exist.

  • runaprl.ps1: Executes the downloaded ARG queries and PowerShell scripts in the queries folder against your Azure subscription.

    • You must have completed Connect-AzAccount and Set-AzContext correctly before run this script.

    • This script requires Az.ResourceGraph, Az.Accounts and Az.Resources modules. You can install those modules by the following command if you have not installed these modules.

      Install-Module -Name 'Az.ResourceGraph', 'Az.Accounts', 'Az.Resources' -Repository 'PSGallery' -Scope AllUsers -Force
  • saveascsv.ps1: Saves the outputs from runaprl.ps1 as a CSV file. This is a script for convenience to save the output into a CSV file. The default output file path is ./results.csv.

Prerequisites

  • One of the following PowerShell.
  • The scripts tested on Windows, but the scripts may be run on other platforms as well. Feedback is welcome.

Quick start

  1. Download the APRL's contents onto your local filesystem. After running the following command, the APRL's ARG queries & PowerShell scripts are stored in the queries folder in the current directory.

    PS C:\aprl> .\getaprl.ps1
  2. Execute the APRL's ARG queries & PowerShell scripts in the queries folder, and save the result to the ./results.csv file.

    PS C:\aprl> .\runaprl.ps1 | .\saveascsv.ps1

Usage examples

getaprl.ps1

  • Example 1: Download the APRL's contents onto your local filesystem.

    PS C:\aprl> .\getaprl.ps1

runaprl.ps1 and saveascsv.ps1

  • Example 1: Execute the APRL's ARG queries and PowerShell scripts without saving the result to a file.

    PS C:\aprl> .\runaprl.ps1
  • Example 2: Execute the APRL's ARG queries and PowerShell scripts, then save the result to a CSV file using the standard PowerShell cmdlets.

    PS C:\aprl> .\runaprl.ps1 | ConvertTo-Csv -NoTypeInformation | Out-File -LiteralPath './results.csv' -Encoding utf8 -Force
  • Example 3: Execute the APRL's ARG queries and PowerShell scripts, then save the result to a CSV file using the saveascsv.ps1 script. The saveascsv.ps1 script is convenient (less typing) than use standard PowerShell cmdlets.

    PS C:\aprl> .\runaprl.ps1 | .\saveascsv.ps1
  • Example 4: Execute the APRL's ARG queries and PowerShell scripts, then showing the result in a grid view. This is convenient for interacting with the results using UI, or copy and paste to Excel, etc.

    PS C:\aprl> .\runaprl.ps1 | Out-GridView

    NOTE: The Out-GridView cmdlet available on Windows Desktop only. A similar cmdlet for cross-platform version is provided by the ConsoleGuiTools module in the PowerShell Gallery.

License

Copyright (c) 2023-present Takeshi Katano. All rights reserved. This software is released under the MIT License.

Disclaimer: The codes stored herein are my own personal codes and do not related my employer's any way.

About

The helper scripts to utilize the Azure Proactive Resiliency Library (APRL). The scripts allow batch execution of the APRL's queries.

Topics

Resources

License

Stars

Watchers

Forks