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.
After you login to Azure, run the powershell script saved in previous step.