Skip to content

Commit 4da8de9

Browse files
committed
Freshness, adding variables
1 parent ed72d63 commit 4da8de9

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: virtual-machines
66
ms.collection: windows
77
ms.topic: quickstart
88
ms.workload: infrastructure
9-
ms.date: 08/09/2021
9+
ms.date: 02/23/2023
1010
ms.author: cynthn
1111
ms.custom: mvc, devx-track-azurecli, mode-api
1212
---
@@ -27,28 +27,31 @@ To open the Cloud Shell, just select **Try it** from the upper right corner of a
2727

2828
## Create a resource group
2929

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:
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. Replace the value of the `resourcegroup` variable as needed.
3131

3232
```azurecli-interactive
33-
az group create --name myResourceGroup --location eastus
33+
resourcegroup="West US 3"
34+
az group create --name myResourceGroup --location $resourcegroup
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 will 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

4344
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.
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.
@@ -74,15 +77,18 @@ Note your own `publicIpAddress` in the output from your VM. This address is used
7477
To see your VM in action, install the IIS web server.
7578

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

8086
## Open port 80 for web traffic
8187

8288
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:
8389

8490
```azurecli-interactive
85-
az vm open-port --port 80 --resource-group myResourceGroup --name myVM
91+
az vm open-port --port 80 --resource-group $resourcegroup --name $vmname
8692
```
8793

8894
## View the web server in action
@@ -96,7 +102,7 @@ With IIS installed and port 80 now open on your VM from the Internet, use a web
96102
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:
97103

98104
```azurecli-interactive
99-
az group delete --name myResourceGroup
105+
az group delete --name $resourcegroup
100106
```
101107

102108
## Next steps

0 commit comments

Comments
 (0)