AZ-900

Microsoft Learn

Cybrary

AZ-103

Deploy using PowerShell

# create resource group
$rgName = "test-rg"
$location = "Central US"
New-AzResourceGroup -Name $rgName -location $location

# create virtual network and subnets
$subnets = @()
$firstSubnetName = "Subnet1"
$secondSubnetName = "Subnet2"
$firstSubnetAddressSpace = "10.0.1.0/24"
$secondSubnetAddressSpace = "10.0.2.0/24"
$vnetAddressSpace = "10.0.0.0/16"
$vnetName = "test-vnet"
$subnets += New-AzVirtualNetworkSubnetConfig `
	-Name $firstSubnetName `
	-AddressPrefix $firstSubnetAddressSpace
$subnets += New-AzVirtualNetworkSubnetConfig `
	-Name $secondSubnetName `
	-AddressPrefix $secondSubnetAddressSpace
$vnet = New-AzVirtualNetwork `
	-Name $vnetName `
	-ResourceGroupName $rgName `
	-location $location `
	-AddressPrefix $vnetAddressSpace `
	-Subnet $subnets

# set VM size
$vmSize = "Standard_DS2_V2"
$vmName = "test-vm"
$vm = New-AzVMConfig -VMName $vmName -VMSize $vmSize

# set OS
$credentials = Get-Credential
Set-AzVMOperatingSystem `
	-Windows `
	-ComputerName $vmName `
	-Credential $credentials `
	-ProvisionVMAgent `
	-VM $vm

# set OS image
$osName = "MicrosoftWindowsServer"
$offerName = "WindowsServer"
$sku = "2016-Datacenter"
Set-AzVMSourceImage `
	-PublisherName $osName `
	-Offer $offerName `
	-Skus $sku `
	-Version "latest" `
	-VM $vm
Set-AzVMDSDisk -CreateOption fromImage -VM $vm

# create NIC
$nicName = "test-nic"
$nic = NewAzNetowrkInterface `
	-Name $nicName `
	-ResourceGroupName $rgName `
	-Location $location `
	-SubnetID $vnet.Subnets[0].Id
Add-AzVMNetworkInterface -VM $vm -NetworkInterface $nic

# provision VM
New-AzVM -ResourceGroupName $rgName -location
$location -VM $vm

Azure Resource Manager (ARM)

Templates

Storage

Types

VMs