{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "clusterName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Managed Cluster resource."
            }
        },
        "location": {
            "type": "string",
            "metadata": {
                "description": "The location of AKS resource."
            }
        },
        "userInstanceType": {
            "type": "string",
            "defaultValue": "Standard_D8_v5",
            "metadata": {
                "description": "Disk size (in GiB) to provision for each of the agent pool nodes. This value ranges from 0 to 1023. Specifying 0 will apply the default disk size for that agentVMSize."
            }
        },
        "osDiskSizeGB": {
            "type": "int",
            "defaultValue": 30,
            "metadata": {
                "description": "Disk size (in GiB) to provision for each of the agent pool nodes. This value ranges from 0 to 1023. Specifying 0 will apply the default disk size for that agentVMSize."
            }
        },
        "osDiskSizeGBWindows": {
            "type": "int",
            "defaultValue": 100,
            "metadata": {
                "description": "Disk size (in GiB) to provision for each of the windows pool nodes. This value ranges from 0 to 1023. Specifying 0 will apply the default disk size for that agentVMSize."
            }
        },
        "userMaxNodes": {
            "type": "int",
            "defaultValue": 1,
            "metadata": {
                "description": "Maximum num of nodes running in a node pool"
            }
        },
        "userMinNodes": {
            "type": "int",
            "defaultValue": 1,
            "metadata": {
                "description": "Minimum num of nodes running in a node pool"
            }
        },
        "userMinNodesWindows": {
            "type": "int",
            "defaultValue": 0,
            "metadata": {
                "description": "Minimum num of nodes running in a node pool"
            }
        },
        "clusterAutoUpgrade": {
            "type": "string",
            "allowedValues": ["true", "false"],
            "defaultValue": "false",
            "metadata": {
                "description": "Enable auto-upgrade for AKS cluster (stable channel if true, none if false)"
            }
        }
    },
    "resources": [
        {
            "apiVersion": "2023-04-01",
            "dependsOn": [],
            "type": "Microsoft.ContainerService/managedClusters",
            "location": "[parameters('location')]",
            "name": "[parameters('clusterName')]",
            "properties": {
                "dnsPrefix": "[concat(parameters('clusterName'), '-dns')]",
                "enableRBAC": true,
                "agentPoolProfiles": [
                    {
                        "name": "agentpool",
                        "osDiskSizeGB": "[parameters('osDiskSizeGB')]",
                        "count": "[parameters('userMinNodes')]",
                        "enableAutoScaling": true,
                        "minCount": "[parameters('userMinNodes')]",
                        "maxCount": "[parameters('userMaxNodes')]",
                        "vmSize": "[parameters('userInstanceType')]",
                        "osType": "Linux",
                        "storageProfile": "ManagedDisks",
                        "type": "VirtualMachineScaleSets",
                        "mode": "System",
                        "maxPods": 100,
                        "availabilityZones": [
                            "1",
                            "2",
                            "3"
                        ],
                        "enableNodePublicIP": false,
                        "tags": {
                            "browserstack:managedBy": "BrowserStack"
                        },
                        "nodeLabels": {
                            "createdBy": "BrowserStack",
                            "managedBy": "Browserstack"
                        }
                    },
                    {
                        "name": "win",
                        "osDiskSizeGB": "[parameters('osDiskSizeGBWindows')]",
                        "count": "[parameters('userMinNodesWindows')]",
                        "enableAutoScaling": true,
                        "minCount": "[parameters('userMinNodesWindows')]",
                        "maxCount": "[parameters('userMaxNodes')]",
                        "vmSize": "[parameters('userInstanceType')]",
                        "osType": "Windows",
                        "osSKU": "Windows2022",
                        "storageProfile": "ManagedDisks",
                        "type": "VirtualMachineScaleSets",
                        "mode": "User",
                        "maxPods": 100,
                        "enableFIPS": false,
                        "windowsProfile": {},
                        "securityProfile": {
                            "sshAccess": "LocalUser"
                        },
                        "availabilityZones": [
                            "1",
                            "2",
                            "3"
                        ],
                        "enableNodePublicIP": false,
                        "tags": {
                            "browserstack:managedBy": "BrowserStack"
                        },
                        "nodeLabels": {
                            "createdBy": "BrowserStack",
                            "managedBy": "Browserstack"
                        }
                    }
                ],
                "windowsProfile": {
                    "adminUsername": "azureuser",
                    "adminPassword": "Azurepassword@123",
                    "enableCSIProxy": true
                },
                "networkProfile": {
                    "loadBalancerSku": "standard",
                    "networkPlugin": "azure"
                },
                "autoUpgradeProfile": {
                    "upgradeChannel": "[if(equals(parameters('clusterAutoUpgrade'), 'true'), 'stable', 'none')]"
                },
                "disableLocalAccounts": false,
                "aadProfile": {
                    "managed": true,
                    "adminGroupObjectIDs": [],
                    "enableAzureRBAC": true
                },
                "apiServerAccessProfile": {
                    "enablePrivateCluster": false
                },
                "addonProfiles": {
                    "azurepolicy": {
                        "enabled": false
                    },
                    "azureKeyvaultSecretsProvider": {
                        "enabled": false,
                        "config": null
                    }
                },
                "oidcIssuerProfile": {
                  "enabled": true
                },
                "securityProfile": {
                  "workloadIdentity": {
                    "enabled": true
                  }
                },
                "upgradePolicy": {
                    "automaticOSUpgradePolicy": {
                        "enableAutomaticOSUpgrade":  false
                    }
                }
            },
            "tags": {
                "browserstack:managedBy": "BrowserStack"
            },
            "sku": {
                "name": "Base",
                "tier": "Standard"
            },
            "identity": {
                "type": "SystemAssigned"
            }
        }
    ]
}
