Skip to content

Commit 5e133cd

Browse files
authored
Merge pull request #228355 from cynthn/13617-cli
Freshness, adding variables
2 parents 7b23c4f + 2e55f75 commit 5e133cd

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

articles/virtual-machines/windows/quick-create-cli.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ author: cynthn
55
ms.service: virtual-machines
66
ms.collection: windows
77
ms.topic: quickstart
8-
ms.workload: infrastructure
9-
ms.date: 08/09/2021
8+
ms.date: 02/23/2023
109
ms.author: cynthn
1110
ms.custom: mvc, devx-track-azurecli, mode-api
1211
---
@@ -27,28 +26,32 @@ To open the Cloud Shell, just select **Try it** from the upper right corner of a
2726

2827
## Create a resource group
2928

30-
Create a resource group with the [az group create](/cli/azure/group) command. An Azure resource group is a logical container into which Azure resources are deployed and managed. The following example creates a resource group named *myResourceGroup* in the *eastus* location:
29+
Create a resource group with the [az group create](/cli/azure/group) command. An Azure resource group is a logical container into which Azure resources are deployed and managed. The following example creates a resource group named *myResourceGroup* in the *West US 3* location. Replace the value of the variables as needed.
3130

3231
```azurecli-interactive
33-
az group create --name myResourceGroup --location eastus
32+
resourcegroup="myResourceGroupCLI"
33+
location="westus3"
34+
az group create --name $resourcegroup --location $location
3435
```
3536

3637
## Create virtual machine
3738

38-
Create a VM with [az vm create](/cli/azure/vm). The following example creates a VM named *myVM*. This example uses *azureuser* for an administrative user name.
39+
Create a VM with [az vm create](/cli/azure/vm). The following example creates a VM named *myVM*. This example uses *azureuser* for an administrative user name. Replace the values of the variables as needed.
3940

40-
You will need to supply a password that meets the [password requirements for Azure VMs](./faq.yml#what-are-the-password-requirements-when-creating-a-vm-
41-
).
41+
You'll be prompted to supply a password that meets the [password requirements for Azure VMs](./faq.yml#what-are-the-password-requirements-when-creating-a-vm-
42+
).
4243

43-
Using the example below, you will be prompted to enter a password at the command line. You could also add the the `--admin-password` parameter with a value for your password. The user name and password will be used later, when you connect to the VM.
44+
Using the example below, you'll be prompted to enter a password at the command line. You could also add the `--admin-password` parameter with a value for your password. The user name and password will be used when you connect to the VM.
4445

4546
```azurecli-interactive
47+
vmname="myVM"
48+
username="azureuser"
4649
az vm create \
47-
--resource-group myResourceGroup \
48-
--name myVM \
50+
--resource-group $resourcegroup \
51+
--name $vmname \
4952
--image Win2022AzureEditionCore \
5053
--public-ip-sku Standard \
51-
--admin-username azureuser
54+
--admin-username $username
5255
```
5356

5457
It takes a few minutes to create the VM and supporting resources. The following example output shows the VM create operation was successful.
@@ -58,31 +61,35 @@ It takes a few minutes to create the VM and supporting resources. The following
5861
{
5962
"fqdns": "",
6063
"id": "/subscriptions/<guid>/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
61-
"location": "eastus",
64+
"location": "westus3",
6265
"macAddress": "00-0D-3A-23-9A-49",
6366
"powerState": "VM running",
6467
"privateIpAddress": "10.0.0.4",
6568
"publicIpAddress": "52.174.34.95",
66-
"resourceGroup": "myResourceGroup"
69+
"resourceGroup": "myResourceGroupCLI"
70+
"zones": ""
6771
}
6872
```
6973

70-
Note your own `publicIpAddress` in the output from your VM. This address is used to access the VM in the next steps.
74+
Take a note your own `publicIpAddress` in the output when you create your VM. This IP address is used to access the VM later in this article.
7175

7276
## Install web server
7377

7478
To see your VM in action, install the IIS web server.
7579

7680
```azurecli-interactive
77-
az vm run-command invoke -g MyResourceGroup -n MyVm --command-id RunPowerShellScript --scripts "Install-WindowsFeature -name Web-Server -IncludeManagementTools"
81+
az vm run-command invoke -g $resourcegroup \
82+
-n $vmname \
83+
--command-id RunPowerShellScript \
84+
--scripts "Install-WindowsFeature -name Web-Server -IncludeManagementTools"
7885
```
7986

8087
## Open port 80 for web traffic
8188

8289
By default, only RDP connections are opened when you create a Windows VM in Azure. Use [az vm open-port](/cli/azure/vm) to open TCP port 80 for use with the IIS web server:
8390

8491
```azurecli-interactive
85-
az vm open-port --port 80 --resource-group myResourceGroup --name myVM
92+
az vm open-port --port 80 --resource-group $resourcegroup --name $vmname
8693
```
8794

8895
## View the web server in action
@@ -96,7 +103,7 @@ With IIS installed and port 80 now open on your VM from the Internet, use a web
96103
When no longer needed, you can use the [az group delete](/cli/azure/group) command to remove the resource group, VM, and all related resources:
97104

98105
```azurecli-interactive
99-
az group delete --name myResourceGroup
106+
az group delete --name $resourcegroup
100107
```
101108

102109
## Next steps

0 commit comments

Comments
 (0)