Skip to content

Commit 4c7dae7

Browse files
committed
update the use condition tutorial
1 parent 1862f10 commit 4c7dae7

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed
Loading
Loading
Loading

articles/azure-resource-manager/templates/template-tutorial-use-conditions.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,25 @@ To complete this article, you need:
5050
Azure QuickStart Templates is a repository for ARM templates. Instead of creating a template from scratch, you can find a sample template and customize it. The template used in this tutorial is called [Deploy a simple Windows VM](https://azure.microsoft.com/resources/templates/101-vm-simple-windows/).
5151

5252
1. From Visual Studio Code, select **File**>**Open File**.
53-
2. In **File name**, paste the following URL:
53+
1. In **File name**, paste the following URL:
5454

5555
```url
5656
https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-windows/azuredeploy.json
5757
```
5858

59-
3. Select **Open** to open the file.
60-
4. There are five resources defined by the template:
59+
1. Select **Open** to open the file.
60+
1. There are six resources defined by the template:
6161

62-
* `Microsoft.Storage/storageAccounts`. See the [template reference](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts).
63-
* `Microsoft.Network/publicIPAddresses`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses).
64-
* `Microsoft.Network/virtualNetworks`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/virtualnetworks).
65-
* `Microsoft.Network/networkInterfaces`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/networkinterfaces).
66-
* `Microsoft.Compute/virtualMachines`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.compute/virtualmachines).
62+
* [**Microsoft.Storage/storageAccounts**](/azure/templates/Microsoft.Storage/storageAccounts).
63+
* [**Microsoft.Network/publicIPAddresses**](/azure/templates/microsoft.network/publicipaddresses).
64+
* [**Microsoft.Network/networkSecurityGroups**](/azure/templates/microsoft.network/networksecuritygroups).
65+
* [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks).
66+
* [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkinterfaces).
67+
* [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualmachines).
6768

68-
It is helpful to get some basic understanding of the template before customizing it.
69-
5. Select **File**>**Save As** to save a copy of the file to your local computer with the name **azuredeploy.json**.
69+
It is helpful to review the template reference before customizing a template.
70+
71+
1. Select **File**>**Save As** to save a copy of the file to your local computer with the name **azuredeploy.json**.
7072

7173
## Modify the template
7274

@@ -78,12 +80,12 @@ Make two changes to the existing template:
7880
Here is the procedure to make the changes:
7981

8082
1. Open **azuredeploy.json** in Visual Studio Code.
81-
2. Replace the three **variables('storageAccountName')** with **parameters('storageAccountName')** in the whole template.
82-
3. Remove the following variable definition:
83+
1. Replace the three **variables('storageAccountName')** with **parameters('storageAccountName')** in the whole template.
84+
1. Remove the following variable definition:
8385

8486
![Resource Manager template use condition diagram](./media/template-tutorial-use-conditions/resource-manager-tutorial-use-condition-template-remove-storageaccountname.png)
8587

86-
4. Add the following two parameters to the template:
88+
1. Add the following two parameters to the beginning of the parameters section:
8789

8890
```json
8991
"storageAccountName": {
@@ -98,11 +100,13 @@ Here is the procedure to make the changes:
98100
},
99101
```
100102

103+
Press **[ALT]+[SHIFT]+F** to format the template in Visual Studio Code.
104+
101105
The updated parameters definition looks like:
102106

103107
![Resource Manager use condition](./media/template-tutorial-use-conditions/resource-manager-tutorial-use-condition-template-parameters.png)
104108

105-
5. Add the following line to the beginning of the storage account definition.
109+
1. Add the following line to the beginning of the storage account definition.
106110

107111
```json
108112
"condition": "[equals(parameters('newOrExisting'),'new')]",
@@ -113,29 +117,34 @@ Here is the procedure to make the changes:
113117
The updated storage account definition looks like:
114118

115119
![Resource Manager use condition](./media/template-tutorial-use-conditions/resource-manager-tutorial-use-condition-template.png)
116-
6. Update the **storageUri** property of the virtual machine resource definition with the following value:
120+
1. Update the **storageUri** property of the virtual machine resource definition with the following value:
117121

118122
```json
119123
"storageUri": "[concat('https://', parameters('storageAccountName'), '.blob.core.windows.net')]"
120124
```
121125

122126
This change is necessary when you use an existing storage account under a different resource group.
123127

124-
7. Save the changes.
128+
1. Save the changes.
125129

126130
## Deploy the template
127131

128132
Follow the instructions in [Deploy the template](./template-tutorial-create-templates-with-dependent-resources.md#deploy-the-template) to open the Cloud shell and upload the revised template, and then run the following PowerShell script to deploy the template.
129133

134+
> [!IMPORTANT]
135+
> The storage account name must be unique across Azure. The name must have only lowercase letters or numbers. It can be no longer than 24 characters. The storage account name is the project name with "store" appended. Make sure the project name meets the storage account name requirements.
136+
130137
```azurepowershell
131-
$resourceGroupName = Read-Host -Prompt "Enter the resource group name"
132-
$storageAccountName = Read-Host -Prompt "Enter the storage account name"
138+
$projectName = Read-Host -Prompt "Enter a project name that is used to generate resource group name and resource names"
133139
$newOrExisting = Read-Host -Prompt "Create new or use existing (Enter new or existing)"
134140
$location = Read-Host -Prompt "Enter the Azure location (i.e. centralus)"
135141
$vmAdmin = Read-Host -Prompt "Enter the admin username"
136142
$vmPassword = Read-Host -Prompt "Enter the admin password" -AsSecureString
137143
$dnsLabelPrefix = Read-Host -Prompt "Enter the DNS Label prefix"
138144

145+
$resourceGroupName = "${projectName}rg"
146+
$storageAccountName = "${projectName}store"
147+
139148
New-AzResourceGroup -Name $resourceGroupName -Location $location
140149
New-AzResourceGroupDeployment `
141150
-ResourceGroupName $resourceGroupName `

0 commit comments

Comments
 (0)