Creating AKS from ARM template

Varma 1,435 Reputation points
2025-04-05T04:56:43.97+00:00

I have created AKS manually, I saved the template below.

I will delete this AKS in a while, but I need to create after few days. so I just want to use template to avoid manual process. I think only need to change the AKS name, thats it.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "managedClusters_AKS_name": {
            "defaultValue": "AKS",
            "type": "String"
        },
        "virtualNetworks_RG_vnet_externalid": {
            "defaultValue": "/subscriptions/9e6baf99-22ca-4234-948e-7d4a9f8ccd32/resourceGroups/RG/providers/Microsoft.Network/virtualNetworks/RG-vnet",
            "type": "String"
        },
        "publicIPAddresses_c23ff39a_0c2e_417d_b0fd_4641f3f20c8c_externalid": {
            "defaultValue": "/subscriptions/9e6baf99-22ca-4234-948e-7d4a9f8ccd32/resourceGroups/MC_RG_AKS_eastus/providers/Microsoft.Network/publicIPAddresses/c23ff39a-0c2e-417d-b0fd-4641f3f20c8c",
            "type": "String"
        },
        "userAssignedIdentities_AKS_agentpool_externalid": {
            "defaultValue": "/subscriptions/9e6baf99-22ca-4234-948e-7d4a9f8ccd32/resourceGroups/MC_RG_AKS_eastus/providers/Microsoft.ManagedIdentity/userAssignedIdentities/AKS-agentpool",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.ContainerService/managedClusters",
            "apiVersion": "2024-10-01",
            "name": "[parameters('managedClusters_AKS_name')]",
            "location": "eastus",
            "sku": {
                "name": "Base",
                "tier": "Free"
            },
            "identity": {
                "type": "SystemAssigned"
            },
            "properties": {
                "kubernetesVersion": "1.30.10",
                "dnsPrefix": "[concat(parameters('managedClusters_AKS_name'), '-dns')]",
                "agentPoolProfiles": [
                    {
                        "name": "agentpool",
                        "count": 1,
                        "vmSize": "Standard_D2s_v3",
                        "osDiskSizeGB": 128,
                        "osDiskType": "Managed",
                        "kubeletDiskType": "OS",
                        "vnetSubnetID": "[concat(parameters('virtualNetworks_RG_vnet_externalid'), '/subnets/default')]",
                        "maxPods": 110,
                        "type": "VirtualMachineScaleSets",
                        "availabilityZones": [
                            "1",
                            "2",
                            "3"
                        ],
                        "maxCount": 3,
                        "minCount": 1,
                        "enableAutoScaling": true,
                        "scaleDownMode": "Delete",
                        "powerState": {
                            "code": "Running"
                        },
                        "orchestratorVersion": "1.30.10",
                        "enableNodePublicIP": false,
                        "mode": "System",
                        "osType": "Linux",
                        "osSKU": "Ubuntu",
                        "upgradeSettings": {
                            "maxSurge": "10%"
                        },
                        "enableFIPS": false,
                        "securityProfile": {
                            "enableVTPM": false,
                            "enableSecureBoot": false
                        }
                    }
                ],
                "windowsProfile": {
                    "adminUsername": "azureuser",
                    "enableCSIProxy": true
                },
                "servicePrincipalProfile": {
                    "clientId": "msi"
                },
                "addonProfiles": {
                    "azureKeyvaultSecretsProvider": {
                        "enabled": false
                    },
                    "azurepolicy": {
                        "enabled": false
                    }
                },
                "nodeResourceGroup": "[concat('MC_RG_', parameters('managedClusters_AKS_name'), '_eastus')]",
                "enableRBAC": true,
                "supportPlan": "KubernetesOfficial",
                "networkProfile": {
                    "networkPlugin": "azure",
                    "networkPluginMode": "overlay",
                    "networkPolicy": "calico",
                    "networkDataplane": "azure",
                    "loadBalancerSku": "Standard",
                    "loadBalancerProfile": {
                        "managedOutboundIPs": {
                            "count": 1
                        },
                        "effectiveOutboundIPs": [
                            {
                                "id": "[parameters('publicIPAddresses_c23ff39a_0c2e_417d_b0fd_4641f3f20c8c_externalid')]"
                            }
                        ],
                        "backendPoolType": "nodeIPConfiguration"
                    },
                    "podCidr": "10.244.0.0/16",
                    "serviceCidr": "10.0.0.0/16",
                    "dnsServiceIP": "10.0.0.10",
                    "outboundType": "loadBalancer",
                    "podCidrs": [
                        "10.244.0.0/16"
                    ],
                    "serviceCidrs": [
                        "10.0.0.0/16"
                    ],
                    "ipFamilies": [
                        "IPv4"
                    ]
                },
                "identityProfile": {
                    "kubeletidentity": {
                        "resourceId": "[parameters('userAssignedIdentities_AKS_agentpool_externalid')]",
                        "clientId": "02f7a79c-a15a-48cb-a7ce-a2ea7f8e6a74",
                        "objectId": "76ce1d3b-39e3-4a94-896d-006775a7db75"
                    }
                },
                "autoScalerProfile": {
                    "balance-similar-node-groups": "false",
                    "daemonset-eviction-for-empty-nodes": false,
                    "daemonset-eviction-for-occupied-nodes": true,
                    "expander": "random",
                    "ignore-daemonsets-utilization": false,
                    "max-empty-bulk-delete": "10",
                    "max-graceful-termination-sec": "600",
                    "max-node-provision-time": "15m",
                    "max-total-unready-percentage": "45",
                    "new-pod-scale-up-delay": "0s",
                    "ok-total-unready-count": "3",
                    "scale-down-delay-after-add": "10m",
                    "scale-down-delay-after-delete": "10s",
                    "scale-down-delay-after-failure": "3m",
                    "scale-down-unneeded-time": "10m",
                    "scale-down-unready-time": "20m",
                    "scale-down-utilization-threshold": "0.5",
                    "scan-interval": "10s",
                    "skip-nodes-with-local-storage": "false",
                    "skip-nodes-with-system-pods": "true"
                },
                "autoUpgradeProfile": {
                    "upgradeChannel": "patch",
                    "nodeOSUpgradeChannel": "NodeImage"
                },
                "disableLocalAccounts": false,
                "securityProfile": {
                    "imageCleaner": {
                        "enabled": true,
                        "intervalHours": 168
                    },
                    "workloadIdentity": {
                        "enabled": true
                    }
                },
                "storageProfile": {
                    "diskCSIDriver": {
                        "enabled": true
                    },
                    "fileCSIDriver": {
                        "enabled": true
                    },
                    "snapshotController": {
                        "enabled": true
                    }
                },
                "oidcIssuerProfile": {
                    "enabled": true
                },
                "workloadAutoScalerProfile": {},
                "metricsProfile": {
                    "costAnalysis": {
                        "enabled": false
                    }
                }
            }
        },
        {
            "type": "Microsoft.ContainerService/managedClusters/agentPools",
            "apiVersion": "2024-10-01",
            "name": "[concat(parameters('managedClusters_AKS_name'), '/agentpool')]",
            "dependsOn": [
                "[resourceId('Microsoft.ContainerService/managedClusters', parameters('managedClusters_AKS_name'))]"
            ],
            "properties": {
                "count": 1,
                "vmSize": "Standard_D2s_v3",
                "osDiskSizeGB": 128,
                "osDiskType": "Managed",
                "kubeletDiskType": "OS",
                "vnetSubnetID": "[concat(parameters('virtualNetworks_RG_vnet_externalid'), '/subnets/default')]",
                "maxPods": 110,
                "type": "VirtualMachineScaleSets",
                "availabilityZones": [
                    "1",
                    "2",
                    "3"
                ],
                "maxCount": 3,
                "minCount": 1,
                "enableAutoScaling": true,
                "scaleDownMode": "Delete",
                "powerState": {
                    "code": "Running"
                },
                "orchestratorVersion": "1.30.10",
                "enableNodePublicIP": false,
                "mode": "System",
                "osType": "Linux",
                "osSKU": "Ubuntu",
                "upgradeSettings": {
                    "maxSurge": "10%"
                },
                "enableFIPS": false,
                "securityProfile": {
                    "enableVTPM": false,
                    "enableSecureBoot": false
                }
            }
        },
        {
            "type": "Microsoft.ContainerService/managedClusters/maintenanceConfigurations",
            "apiVersion": "2024-10-01",
            "name": "[concat(parameters('managedClusters_AKS_name'), '/', parameters('managedClusters_AKS_name'), 'ManagedAutoUpgradeSchedule')]",
            "dependsOn": [
                "[resourceId('Microsoft.ContainerService/managedClusters', parameters('managedClusters_AKS_name'))]"
            ],
            "properties": {
                "maintenanceWindow": {
                    "schedule": {
                        "weekly": {
                            "intervalWeeks": 1,
                            "dayOfWeek": "Sunday"
                        }
                    },
                    "durationHours": 4,
                    "utcOffset": "+00:00",
                    "startDate": "2025-04-06",
                    "startTime": "00:00"
                }
            }
        },
        {
            "type": "Microsoft.ContainerService/managedClusters/maintenanceConfigurations",
            "apiVersion": "2024-10-01",
            "name": "[concat(parameters('managedClusters_AKS_name'), '/', parameters('managedClusters_AKS_name'), 'ManagedNodeOSUpgradeSchedule')]",
            "dependsOn": [
                "[resourceId('Microsoft.ContainerService/managedClusters', parameters('managedClusters_AKS_name'))]"
            ],
            "properties": {
                "maintenanceWindow": {
                    "schedule": {
                        "weekly": {
                            "intervalWeeks": 1,
                            "dayOfWeek": "Sunday"
                        }
                    },
                    "durationHours": 4,
                    "utcOffset": "+00:00",
                    "startDate": "2025-04-06",
                    "startTime": "00:00"
                }
            }
        }
    ]
}

Can you please suggest high level steps how it can be done. Thank you

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,348 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Luke Murray 11,351 Reputation points MVP
    2025-04-05T05:06:51.3166667+00:00

    Hi, you can go to: Custom deployment

    Select Build your own, and you can upload or add in ARM template. Another thing you can do, if you still have the Resource Group that the AKS cluster was in, was go to Deployments pane and redeploy from there.

    Future recommendations would be to look at IaC (Infrastructure as Code) with Terraform or Bicep and deploy from there. Deployment stacks might be of interest cause you can delete and use that to redeploy within the portal.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.