Skip to content
Menu
Tech Automation Blog
  • About Author
  • Contact
Tech Automation Blog

Azure Kubernetes Service (AKS) resource inventory

Posted on September 2, 2019February 27, 2022

Update : updated script to support Azure Az powershell module.

Azure Kubernetes Service is a managed service on Cloud by Microsoft that lets you quickly deploy and manage Kubernetes Clusters. It helps quickly and easily deploy and manage containerized applications. It offers serverless Kubernetes, an integrated continuous integration and continuous delivery (CI/CD) experience. AKS helps elastic provisioning of resources quickly without the need to manage infrastructure. It also provides enhanced security by integrating it with Azure Active Directory and Azure Policies.

Refer here to learn more about AKS. For a quick start on AKS refer Microsoft Documentation.

Here is a sample powershell script to quickly generate an inventory of deployed Azure Kubernetes Service cluster in Azure Cloud environment. It generates a csv file with basic information of AKS Clusters.  This script executes against all subscriptions within a Tenant using the provided login credentials.

Azure Az Module must be installed and imported on the system before running this script.

Refer following article for more information on this module : https://docs.microsoft.com/en-us/powershell/azure/new-azureps-module-az?view=azps-5.5.0

$date = Get-Date -UFormat "%m-%d-%Y"
$currentDir = $(Get-Location).Path
$oFile = "$($currentDir)\Azure_AKS_Details_$($date).csv"
if(Test-Path $oFile){Remove-Item $oFile -Force}
"SubscriptionName,AKSClusterName,AKSClusterFQDN,ResourcegRoupName,Location,KubernetVersion" | Out-File $oFile -Append -Encoding ASCII
Get-AzSubscription | ForEach-Object{
	$subscriptionId = $subscriptionName = ""
	$subscriptionId = $_.SubscriptionId
	$subscriptionName = $_.Name
        Set-AzContext -SubscriptionId $subscriptionId
        Get-AzAKS | ForEach-Object {
        $aksCluName = $aksCluFQDN = $resourceGroup = $location = $kubVersion = ""
        $aksCluName = $_.Name
        $aksCluFQDN = $_.Fqdn
        $resourceGroup =  $_.Id.Split("/")[4]
        $location = $_.Location
        $kubVersion = $_.KubernetesVersion
        "$subscriptionName,$aksCluName,$aksCluFQDN,$resourceGroup,$location,$kubVersion" | Out-File $oFile -Append -Encoding ASCII
    }
}

Download above script and save it with a .ps1 file extension. Open powershell console and, login to your Azure account using – Login-AzAccount. It will prompt you to enter your Azure credentials.

This image has an empty alt attribute; its file name is image-3.png
Login to Azure Account

After you login to Azure, run the powershell script saved in previous step.

Execute powershell script

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
July 2025
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  
« May    

Recent Posts

  • Monitor and alert Azure Service Health issues May 5, 2020
  • AWS IAM User access review May 3, 2020
  • Integrate Azure Security Center with Event Hub April 28, 2020
  • Add Tags to Azure Subscription April 24, 2020
  • Automate Azure billing report in Excel March 6, 2020

Categories

©2025 Tech Automation Blog | Powered by SuperbThemes