Ein Powershell Script als Beispiel.
Install-Module -Name Az -AllowClobber -Scope CurrentUser
Connect-AzAccount
/* create a resource group */
New-AzResourceGroup -Name "MyResourceGroup" -Location "East US"
/* create VM */
$vmConfig = New-AzVMConfig -VMName "MyVM" -VMSize "Standard_DS2_v2"
$vmConfig = Set-AzVMOperatingSystem -VM $vmConfig -Windows -ComputerName "MyVM" -Credential (Get-Credential)
$vmConfig = Set-AzVMSourceImage -VM $vmConfig -PublisherName "MicrosoftWindowsServer" -Offer "WindowsServer" -Skus "2019-Datacenter" -Version "latest"
$vmConfig = Add-AzVMNetworkInterface -VM $vmConfig -Id (Get-AzNetworkInterface -ResourceGroupName "MyResourceGroup" -Name "MyNIC").Id
New-AzVM -ResourceGroupName "MyResourceGroup" -Location "East US" -VM $vmConfig