Automating the tasks
As usual at the end of each chapter, we get our hands dirty with automation.
Creating an Azure VM using PowerShell
Creating an Azure VM is one of the most common tasks on Azure, so let's get started.
First off, let's create the resources that make up the VM, and let's kick off with network resources.
Network resources
Every VM requires some network resources to be able to function properly, such as a subnet, virtual network, public IP address, and network security group (NSG), as shown in the following cmdlets:
$Subnet = New-AzureRmVirtualNetworkSubnetConfig -Name PacktPubSubnet -AddressPrefix 10.0.0.0/24 $VirtualNetwork = New-AzureRmVirtualNetwork -ResourceGroupName PacktPub -Location WestEurope -Name PacktPubvNet -AddressPrefix 10.0.0.0/8 -Subnet $Subnet $PIP = New-AzureRmPublicIpAddress -ResourceGroupName PacktPub -Location WestEurope -AllocationMethod Dynamic -Name PacktPubVMPIP
Now we are done with the main network components, but the VM will require a firewall named NSG...