Quickstart - Create a Windows VM with Azure PowerShell - Azure Virtual Machines (2024)

  • Article

Applies to: ✔️ Windows VMs

The Azure PowerShell module is used to create and manage Azure resources from the PowerShell command line or in scripts. This quickstart shows you how to use the Azure PowerShell module to deploy a virtual machine (VM) in Azure that runs Windows Server 2016. You also bring Remote Desktop Portal (RDP) to the VM and install the IIS web server, to show the VM in action.

If you don't have an Azure subscription, create a free account before you begin.

Launch Azure Cloud Shell

The Azure Cloud Shell is a free interactive shell you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account.

To open the Cloud Shell, just select Open Cloudshell from the upper right corner of a code block. You can also launch Cloud Shell in a separate browser tab by going to https://shell.azure.com/powershell. Select Copy to copy the code blocks, paste them into the Cloud Shell, and press enter to run the them.

Create resource group

Create an Azure resource group with New-AzResourceGroup. A resource group is a logical container into which Azure resources are deployed and managed.

New-AzResourceGroup -Name 'myResourceGroup' -Location 'eastus'

Create virtual machine

Create a VM with New-AzVM. Provide names for each of the resources and the New-AzVM cmdlet creates if they don't already exist.

When prompted, provide a username and password to be used as the sign-in credentials for the VM:

New-AzVm ` -ResourceGroupName 'myResourceGroup' ` -Name 'myVM' ` -Location 'eastus' ` -Image 'MicrosoftWindowsServer:WindowsServer:2022-datacenter-azure-edition:latest' ` -VirtualNetworkName 'myVnet' ` -SubnetName 'mySubnet' ` -SecurityGroupName 'myNetworkSecurityGroup' ` -PublicIpAddressName 'myPublicIpAddress' ` -OpenPorts 80,3389

Cost information isn't presented during the virtual machine creation process for PowerShell like it is for the Azure portal. If you want to learn more about how cost works for virtual machines, see the Cost optimization Overview page.

Install web server

To see your VM in action, install the IIS web server. Open a PowerShell prompt on the VM and run the following command:

Invoke-AzVMRunCommand -ResourceGroupName 'myResourceGroup' -VMName 'myVM' -CommandId 'RunPowerShellScript' -ScriptString 'Install-WindowsFeature -Name Web-Server -IncludeManagementTools'

The -ScriptString parameter requires version 4.27.0 or later of the Az.Compute module.

View the web server in action

With IIS installed and port 80 now open on your VM from the Internet, use a web browser of your choice to view the default IIS welcome page. Use the public IP address of the VM that you created. The following example shows the default IIS web site:

Quickstart - Create a Windows VM with Azure PowerShell - Azure Virtual Machines (1)

Clean up resources

When no longer needed, you can use the Remove-AzResourceGroup cmdlet to remove the resource group, VM, and all related resources:

Remove-AzResourceGroup -Name 'myResourceGroup'

Next steps

In this quickstart, you deployed a simple virtual machine, opened a network port for web traffic, and installed a basic web server. To learn more about Azure virtual machines, continue to the tutorial for Windows VMs.

Quickstart - Create a Windows VM with Azure PowerShell - Azure Virtual Machines (2024)
Top Articles
Security Questions: Best Practices, Examples, and Ideas
Top 10 largest car insurance companies in the U.S.
Mickey Moniak Walk Up Song
Craigslist Myrtle Beach Motorcycles For Sale By Owner
Le Blanc Los Cabos - Los Cabos – Le Blanc Spa Resort Adults-Only All Inclusive
Chicago Neighborhoods: Lincoln Square & Ravenswood - Chicago Moms
Falgout Funeral Home Obituaries Houma
Professor Qwertyson
Walgreens Alma School And Dynamite
Moviesda Dubbed Tamil Movies
Myunlb
Lonadine
Colts seventh rotation of thin secondary raises concerns on roster evaluation
Truck Toppers For Sale Craigslist
Clarksburg Wv Craigslist Personals
Craigslist Apartments In Philly
A rough Sunday for some of the NFL's best teams in 2023 led to the three biggest upsets: Analysis - NFL
Craigslist Free Stuff Santa Cruz
Sport-News heute – Schweiz & International | aktuell im Ticker
Parent Resources - Padua Franciscan High School
Nail Salon Goodman Plaza
Itziar Atienza Bikini
NBA 2k23 MyTEAM guide: Every Trophy Case Agenda for all 30 teams
Costco Great Oaks Gas Price
Beryl forecast to become an 'extremely dangerous' Category 4 hurricane
Play It Again Sports Norman Photos
Ihub Fnma Message Board
Bocca Richboro
Wsbtv Fish And Game Report
Datingscout Wantmatures
Used 2 Seater Go Karts
Swgoh Boba Fett Counter
Navigating change - the workplace of tomorrow - key takeaways
Tendermeetup Login
Royals op zondag - "Een advertentie voor Center Parcs" of wat moeten we denken van de laatste video van prinses Kate?
Wednesday Morning Gifs
Etowah County Sheriff Dept
Grapes And Hops Festival Jamestown Ny
Pitchfork's Top 200 of the 2010s: 50-1 (clips)
Hell's Kitchen Valley Center Photos Menu
Lamp Repair Kansas City Mo
Exam With A Social Studies Section Crossword
Value Village Silver Spring Photos
The Pretty Kitty Tanglewood
Walmart Front Door Wreaths
Madden 23 Can't Hire Offensive Coordinator
53 Atms Near Me
Wild Fork Foods Login
Round Yellow Adderall
Aspen.sprout Forum
Overstock Comenity Login
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 5534

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.