Generally speaking the process are two parts.
The 1st part is to provision the resources on Azure platform like control plane, networking, identity and virtual machine.
The really magic part is the execution “custom script extension”. Below is a brief introduction about how does it work
Create a nodepool with Windows node and navigate to the node resource group AKS created. Usually it’s named with ‘MC’ as prefix.
Open the “Deployments” and the deployment detail of the windows nodepool
Search the keyword “customdata” in the template detail. The value of this field will be encoded with base64 during the VM provision.
Search the keyword “CommandToExecute” in the template detail. The value of this field is the command which will be executed after the OS boots. The variable “windowsCustomScriptSuffix” is to rename the ‘bin’ file containing the custom data mentioned in last step to a Powershell script and execute it with arguments.
When there is custom script extension failure, for further troubleshooting, you could SSH to the node and review the log “%SYSTEMDRIVE%\\AzureData\\CustomDataSetupScript.log”. Also compare the script mentioned in Custom Data to understand what it does.