Skip to content

Commit 2f8d34b

Browse files
authored
Merge pull request #97725 from mumian/master
update the linked template tutorial
2 parents 864b7d2 + 31708e7 commit 2f8d34b

File tree

3 files changed

+43
-47
lines changed

3 files changed

+43
-47
lines changed
Loading

articles/azure-resource-manager/resource-manager-tutorial-create-linked-templates.md

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Create linked templates
33
description: Learn how to create linked Azure Resource Manager templates for creating virtual machine
44
author: mumian
5-
ms.date: 10/04/2019
5+
ms.date: 12/03/2019
66
ms.topic: tutorial
77
ms.author: jgao
88
---
@@ -40,6 +40,7 @@ To complete this article, you need:
4040
```azurecli-interactive
4141
openssl rand -base64 32
4242
```
43+
4344
Azure Key Vault is designed to safeguard cryptographic keys and other secrets. For more information, see [Tutorial: Integrate Azure Key Vault in Resource Manager Template deployment](./resource-manager-tutorial-use-key-vault.md). We also recommend you to update your password every three months.
4445
4546
## Open a Quickstart template
@@ -50,42 +51,46 @@ Azure QuickStart Templates is a repository for Resource Manager templates. Inste
5051
* **The linked template**: create the storage account.
5152
5253
1. From Visual Studio Code, select **File**>**Open File**.
53-
2. In **File name**, paste the following URL:
54+
1. In **File name**, paste the following URL:
5455
5556
```url
5657
https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-windows/azuredeploy.json
5758
```
58-
3. Select **Open** to open the file.
59-
4. There are five resources defined by the template:
59+
60+
1. Select **Open** to open the file.
61+
1. There are six resources defined by the template:
6062
6163
* [`Microsoft.Storage/storageAccounts`](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts)
6264
* [`Microsoft.Network/publicIPAddresses`](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses)
65+
* [`Microsoft.Network/networkSecurityGroups`](https://docs.microsoft.com/azure/templates/microsoft.network/networksecuritygroups)
6366
* [`Microsoft.Network/virtualNetworks`](https://docs.microsoft.com/azure/templates/microsoft.network/virtualnetworks)
6467
* [`Microsoft.Network/networkInterfaces`](https://docs.microsoft.com/azure/templates/microsoft.network/networkinterfaces)
6568
* [`Microsoft.Compute/virtualMachines`](https://docs.microsoft.com/azure/templates/microsoft.compute/virtualmachines)
6669
6770
It is helpful to get some basic understanding of the template schema before customizing the template.
68-
5. Select **File**>**Save As** to save a copy of the file to your local computer with the name **azuredeploy.json**.
69-
6. Select **File**>**Save As** to create another copy of the file with the name **linkedTemplate.json**.
71+
1. Select **File**>**Save As** to save a copy of the file to your local computer with the name **azuredeploy.json**.
72+
1. Select **File**>**Save As** to create another copy of the file with the name **linkedTemplate.json**.
7073
7174
## Create the linked template
7275
7376
The linked template creates a storage account. The linked template can be used as a standalone template to create a storage account. In this tutorial, the linked template takes two parameters, and passes a value back to the main template. This "return" value is defined in the `outputs` element.
7477
7578
1. Open **linkedTemplate.json** in Visual Studio Code if the file is not opened.
76-
2. Make the following changes:
79+
1. Make the following changes:
7780
7881
* Remove all the parameters other than **location**.
7982
* Add a parameter called **storageAccountName**.
80-
```json
81-
"storageAccountName":{
82-
"type": "string",
83-
"metadata": {
84-
"description": "Azure Storage account name."
85-
}
86-
},
87-
```
88-
The storage account name and location are passed from the main template to the linked template as parameters.
83+
84+
```json
85+
"storageAccountName":{
86+
"type": "string",
87+
"metadata": {
88+
"description": "Azure Storage account name."
89+
}
90+
},
91+
```
92+
93+
The storage account name and location are passed from the main template to the linked template as parameters.
8994
9095
* Remove the **variables** element, and all the variable definitions.
9196
* Remove all the resources other than the storage account. You remove a total of four resources.
@@ -105,6 +110,7 @@ The linked template creates a storage account. The linked template can be used a
105110
}
106111
}
107112
```
113+
108114
**storageUri** is required by the virtual machine resource definition in the main template. You pass the value back to the main template as an output value.
109115
110116
When you are done, the template shall look like:
@@ -133,7 +139,7 @@ The linked template creates a storage account. The linked template can be used a
133139
"type": "Microsoft.Storage/storageAccounts",
134140
"name": "[parameters('storageAccountName')]",
135141
"location": "[parameters('location')]",
136-
"apiVersion": "2018-07-01",
142+
"apiVersion": "2018-11-01",
137143
"sku": {
138144
"name": "Standard_LRS"
139145
},
@@ -149,7 +155,8 @@ The linked template creates a storage account. The linked template can be used a
149155
}
150156
}
151157
```
152-
3. Save the changes.
158+
159+
1. Save the changes.
153160
154161
## Upload the linked template
155162
@@ -203,9 +210,10 @@ $templateURI = New-AzStorageBlobSASToken `
203210
-ExpiryTime (Get-Date).AddHours(8.0) `
204211
-FullUri
205212
206-
echo "You need the following values later in the tutorial:"
207-
echo "Resource Group Name: $resourceGroupName"
208-
echo "Linked template URI with SAS token: $templateURI"
213+
Write-Host "You need the following values later in the tutorial:"
214+
Write-Host "Resource Group Name: $resourceGroupName"
215+
Write-Host "Linked template URI with SAS token: $templateURI"
216+
Write-Host "Press [ENTER] to continue ..."
209217
```
210218

211219
1. Select the **Try It** green button to open the Azure cloud shell pane.
@@ -221,22 +229,7 @@ In practice, you generate a SAS token when you deploy the main template, and giv
221229
The main template is called azuredeploy.json.
222230

223231
1. Open **azuredeploy.json** in Visual Studio Code if it is not opened.
224-
2. Delete the storage account resource definition from the template:
225-
226-
```json
227-
{
228-
"type": "Microsoft.Storage/storageAccounts",
229-
"name": "[variables('storageAccountName')]",
230-
"location": "[parameters('location')]",
231-
"apiVersion": "2018-07-01",
232-
"sku": {
233-
"name": "Standard_LRS"
234-
},
235-
"kind": "Storage",
236-
"properties": {}
237-
},
238-
```
239-
3. Add the following json snippet to the place where you had the storage account definition:
232+
1. Replace the storage account resource definition with the following json snippet:
240233

241234
```json
242235
{
@@ -246,7 +239,7 @@ The main template is called azuredeploy.json.
246239
"properties": {
247240
"mode": "Incremental",
248241
"templateLink": {
249-
"uri":"https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorial-linked-templates/linkedStorageAccount.json"
242+
"uri":""
250243
},
251244
"parameters": {
252245
"storageAccountName":{"value": "[variables('storageAccountName')]"},
@@ -263,8 +256,8 @@ The main template is called azuredeploy.json.
263256
* You can only use [Incremental](./deployment-modes.md) deployment mode when calling linked templates.
264257
* `templateLink/uri` contains the linked template URI. Update the value to the URI you get when you upload the linked template (the one with a SAS token).
265258
* Use `parameters` to pass values from the main template to the linked template.
266-
4. Make sure you have updated the value of the `uri` element to the value you got when you upload the linked template (the one with a SAS token). In practice, you want to supply the URI with a parameter.
267-
5. Save the revised template
259+
1. Make sure you have updated the value of the `uri` element to the value you got when you upload the linked template (the one with a SAS token). In practice, you want to supply the URI with a parameter.
260+
1. Save the revised template
268261

269262
## Configure dependency
270263

@@ -285,6 +278,7 @@ Because the storage account is defined in the linked template now, you must upda
285278
}
286279
}
287280
```
281+
288282
This value is required by the main template.
289283

290284
1. Open azuredeploy.json in Visual Studio Code if it is not opened.

articles/azure-resource-manager/resource-manager-tutorial-create-templates-with-dependent-resources.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ When you explore the template in this section, try to answer these questions:
8181
![Visual Studio Code Azure Resource Manager templates public IP address definition](./media/resource-manager-tutorial-create-templates-with-dependent-resources/resource-manager-template-public-ip-address-definition.png)
8282
4. Expand the fourth resource. The resource type is `Microsoft.Network/networkInterfaces`:
8383
84-
![Visual Studio Code Azure Resource Manager templates dependson](./media/resource-manager-tutorial-create-templates-with-dependent-resources/resource-manager-template-visual-studio-code-dependson.png)
84+
![Visual Studio Code Azure Resource Manager templates dependsOn](./media/resource-manager-tutorial-create-templates-with-dependent-resources/resource-manager-template-visual-studio-code-dependson.png)
8585
8686
The dependsOn element enables you to define one resource as a dependent on one or more resources. The resource depends on two other resources:
8787
@@ -106,15 +106,15 @@ By specifying the dependencies, Resource Manager efficiently deploys the solutio
106106
There are many methods for deploying templates. In this tutorial, you use Cloud Shell from the Azure portal.
107107
108108
1. Sign in to the [Cloud Shell](https://shell.azure.com).
109-
2. Select **PowerShell** from the upper left corner of the Cloud shell, and then select **Confirm**. You use PowerShell in this tutorial.
110-
3. Select **Upload file** from the Cloud shell:
109+
1. Select **PowerShell** from the upper left corner of the Cloud shell, and then select **Confirm**. You use PowerShell in this tutorial.
110+
1. Select **Upload file** from the Cloud shell:
111111
112112
![Azure portal Cloud shell upload file](./media/resource-manager-tutorial-create-templates-with-dependent-resources/azure-portal-cloud-shell-upload-file.png)
113-
4. Select the template you saved earlier in the tutorial. The default name is **azuredeploy.json**. If you have a file with the same file name, the old file is overwritten without any notification.
113+
1. Select the template you saved earlier in the tutorial. The default name is **azuredeploy.json**. If you have a file with the same file name, the old file is overwritten without any notification.
114114
115115
You can optionally use the **ls $HOME** command and the **cat $HOME/azuredeploy.json** command to verify the files areis uploaded successfully.
116116
117-
5. From the Cloud shell, run the following PowerShell commands. To increase security, use a generated password for the virtual machine administrator account. See [Prerequisites](#prerequisites).
117+
1. From the Cloud shell, run the following PowerShell commands. To increase security, use a generated password for the virtual machine administrator account. See [Prerequisites](#prerequisites).
118118
119119
```azurepowershell
120120
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
@@ -130,18 +130,20 @@ There are many methods for deploying templates. In this tutorial, you use Cloud
130130
-adminPassword $adminPassword `
131131
-dnsLabelPrefix $dnsLabelPrefix `
132132
-TemplateFile "$HOME/azuredeploy.json"
133+
Write-Host "Press [ENTER] to continue ..."
133134
```
134135
135-
8. Run the following PowerShell command to list the newly created virtual machine:
136+
1. Run the following PowerShell command to list the newly created virtual machine:
136137
137138
```azurepowershell
138139
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
139140
Get-AzVM -Name SimpleWinVM -ResourceGroupName $resourceGroupName
141+
Write-Host "Press [ENTER] to continue ..."
140142
```
141143
142144
The virtual machine name is hard-coded as **SimpleWinVM** inside the template.
143145
144-
9. RDP to the virtual machine to verify the virtual machine has been created successfully.
146+
1. RDP to the virtual machine to verify the virtual machine has been created successfully.
145147
146148
## Clean up resources
147149

0 commit comments

Comments
 (0)