Recently in one of the Azure project my client was utilizing Azure Reservations Instances (Azure RI) they wanted a Microsoft PowerShell script from me to pull the list report. Below is the screenshot of all configured reservations on the Azure Portal.
To work on Azure Reservations with PowerShell, you require Az.Reservations module, if you don't installed on your system, you can download it with below command.
Install-Module -Name Az.Reservations -Scope CurrentUser
Every Reservation has Order ID, it is a GUID, these IDs can be retrieved using below command.
Get-AzReservationOrderId #list
Once you have Reservation Order ID, more details about it can be fetched using below one-liner cmdlet.
#$reservationOrderId = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX' #GUID #Get-AzReservation -ReservationOrderId $reservationOrderId (Get-AzReservationOrderId).AppliedReservationOrderId | % {Get-AzReservation -ReservationOrderId ($_ -split '/')[-1]}
If you are looking for AzureCLI scripts use below commands to automate reports.
az reservations reservation-order list az reservations reservation list –reservation-order-id XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX
Useful Articles
Part 1: Working With Azure Key Vault Using Azure PowerShell and AzureCLI
Part 2: Create a Virtual machine on Microsoft Azure
Part 3: Use a Azure VM system assigned managed identity to access Azure Key Vault
Create an Azure App registrations in Azure Active Directory using PowerShell & AzureCLI
Connect-AzureAD: One or more errors occurred. Could not load type 'System.Security.Cryptography.SHA256Cng'
Use Key Vault secret identifier url to get the secret value using Powershell
Working With Azure Key Vault Using Azure PowerShell and AzureCLI
Create key vault and secrets with access policies in Microsoft Azure
Creating a new user in Azure AD using oneliner PowerShell and Azure CLI
How to switch to other Azure AD tenant using PowerShell and Azure CLI