I wanted to explore the benefits of Azure ARM VMs that run on Arm-based processors. They offer outstanding price-performance and power-efficiency for various workloads. In this snippet, I show how to deploy a Generation 2 Windows 11 ARM virtual machine with basic naming standard and diagnostics using PowerShell cmdlets.
This stores the name in a variable, creates a resource group and parameterizes the location and Resource Group name for splatting.
$Location= 'NorthCentralUS'
$Name = 'Win11ARM'
$RG = New-AzResourceGroup -Location $Location -Name ($Name+'RG')
$Params = @{ResourceGroupName = $RG.ResourceGroupName; Location = $Location; Verbose=$true}
This is the network configuration to create an NSG allowing remote desktop connections and a public IP address pointing to the accelerated networking enabled network card that the virtual machine would use. Add the IP where the RDP connection would come from.
#Network configuration
$RDParams= @{Name= "$Name'RDPRule'"; Description= 'Allow RDP'; Access= 'Allow'; Protocol= 'Tcp'; Direction= 'Inbound'; SourcePortRange= '*'; DestinationPortRange= '3389'}
$RDPRule = New-AzNetworkSecurityRuleConfig @RDPParams -Priority 200 -SourceAddressPrefix <YourIP> -DestinationAddressPrefix VirtualNetwork
$NSG = New-AzNetworkSecurityGroup @Params -Name $Name'NSG' -SecurityRules $RDPRule
$Subnet = New-AzVirtualNetworkSubnetConfig -Name Default -AddressPrefix 192.168.0.0/29 -NetworkSecurityGroup $NSG
$Vnet = New-AzVirtualNetwork @Params -Name $Name'VN' -AddressPrefix 192.168.0.0/28 -Subnet $Subnet
$PIP = New-AzPublicIpAddress @Params -Name $Name'PIP' -AllocationMethod Dynamic -Sku Basic -DomainNameLabel $Name.ToLower()
$NIC = New-AzNetworkInterface @Params -Name $Name'NIC' -SubnetId $Vnet.Subnets[0].Id -PublicIpAddressId $PIP.Id -EnableAcceleratedNetworking
The virtual machine configuration specifies the name, size, credentials, time zone, image details, update behavior and diagnostics configuration of the VM. Add your password.
#Virtual Machine Configuration
$cred = New-Object System.Management.Automation.PSCredential "admin",$(ConvertTo-SecureString '<YourPassword>' -asplaintext -force)
$vmConfig= New-AzVMConfig -VMName $Name'VM' -VMSize Standard_E4ps_v5 -LicenseType Windows_Client|
Set-AzVMOperatingSystem -Windows -ComputerName $Name'VM' -Credential $cred -TimeZone 'Central Standard Time' -ProvisionVMAgent -EnableAutoUpdate|
Set-AzVMSourceImage -PublisherName MicrosoftWindowsDesktop -Offer windows11preview-arm64 -Skus win11-22h2-ent -Version latest|
Set-AzVMOSDisk -Name $Name'D' -Caching ReadWrite -CreateOption FromImage|
Add-AzVMNetworkInterface -Id $NIC.Id|Set-AzVMBootDiagnostic -ResourceGroupName $RG.ResourceGroupName -Enable
New-AzVM @Params -VM $vmConfig #Deploys the VM
Output
RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK
The Windows ARM image is still in preview and doesn't support Trusted Launch or Secure Boot yet and it's for validation purposes only.
Top comments (0)