Create the VM with pre-configuration such as installed windows features and roles.
Step 1: Create new VM script:
You have to create a script to get new Azure VM ready with provided details. You need to then inject one script (custom script) with other script (Azure automation).
Let us view a script for creating new vm as follows:
Step 2: Inject script:
While creating Azure VM with GUI, put this as custom script
But with command line for automation, we need to put custom script in Azure storage that is blob (recommended). For injecting the script which is required for installing pre-requisites such as windows roles and features installation, create a custom script. Store it on Azure blob. Call it with the following syntax:
Set-AzureVMCustomScriptExtension -VM $vm -ContainerName vhds -filename 'custom.ps1'
Here custom.ps1 is another ps script which has to be injected on Azure vm using the following steps:
Install-WindowsFeature BITS -IncludeAllSubFeature -IncludeManagementTools -Restart
Step 3: Now run script with PowerShell. The VM is ready with all the necessary prerequisites.
Note: Check for Default azure storage account and Azure account before running script.
Use the following command for current Azure account as well as storage account
Get-AzureSubscription