Let's create a virtual machine using windows powershell.
I will advise you make use of windows powershell 7. If you don't have it, download it.
What is Powershell and what is it used for ?
PowerShell, based on Microsoft .NET technology, serves as a versatile attribute with dual functionality. It can function as both an open-source shell and a scripting language. When utilized as a shell, PowerShell enables the control of a computer through commands issued via a command-line interface, specifically pertaining to the operating system.
Here are basic steps in creating your virtual machine on powershell;
Step 1 : Install Azure PowerShell Module
You will have to install the azure powershell module using this command -“Install-Module -Name Az -AllowClobber -Force -Scope CurrentUser”
N.B - If you have this installed just like i have, you don't have to reinstall
Step 2: Connect to your Azure Account
Next you have to connect your Azure account, make sure you have an active subscription and log in to your account. The command to connect to is Connect-AzAccount
Step 3 : create a resource group
Note that if you have an existing and active resource group on your azure subscription, you don't have to create a resource group.
To create a resource group, use the command New-AzResourceGroup -Name -Location
Step 4 : Create your virtual machine
Now you can go ahead and create your virtual machine using this command but make sure to fill in your own parameters and names
New-AzVM -Name teevm -ResourceGroup teerg -Location eastus -Image Ubuntu2204 -VirtualNetworkName teenet -SubnetName teesubnet -SecurityGroupName teesec -PublicIpAddressName teeip -OpenPorts 80,3389
To create the Virtual machine , a user and password is required.
Once vm is created it will bring out the details just like this;
Yippee... Congratulations mate🎉
At this point you've installed the Azure PowerShell module, connected it to your Azure account and have successfully automated the deployment of a virtual machine.
Top comments (0)