Skip to content

Commit 50ec3bc

Browse files
authored
Merge pull request #110962 from mumian/0409-dependent
update the dependent tutorial
2 parents 421566c + a1e5159 commit 50ec3bc

7 files changed

+36
-31
lines changed
Loading

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

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
title: Template with dependent resources
33
description: Learn how to create an Azure Resource Manager template with multiple resources, and how to deploy it using the Azure portal
44
author: mumian
5-
ms.date: 03/04/2019
5+
ms.date: 04/10/2020
66
ms.topic: tutorial
77
ms.author: jgao
88
---
99

1010
# Tutorial: Create ARM templates with dependent resources
1111

12-
Learn how to create an Azure Resource Manager (ARM) template to deploy multiple resources and configure the deployment order. After you create the template, you deploy the template using the Cloud shell from the Azure portal.
12+
Learn how to create an Azure Resource Manager (ARM) template to deploy multiple resources and configure the deployment order. After you create the template, you deploy the template using the Cloud Shell from the Azure portal.
1313

1414
In this tutorial, you create a storage account, a virtual machine, a virtual network, and some other dependent resources. Some of the resources cannot be deployed until another resource exists. For example, you can't create the virtual machine until its storage account and network interface exist. You define this relationship by making one resource as dependent on the other resources. Resource Manager evaluates the dependencies between resources, and deploys them in their dependent order. When resources aren't dependent on each other, Resource Manager deploys them in parallel. For more information, see [Define the order for deploying resources in ARM templates](./define-resource-dependency.md).
1515

@@ -34,6 +34,7 @@ To complete this article, you need:
3434
```console
3535
openssl rand -base64 32
3636
```
37+
3738
Azure Key Vault is designed to safeguard cryptographic keys and other secrets. For more information, see [Tutorial: Integrate Azure Key Vault in ARM template deployment](./template-tutorial-use-key-vault.md). We also recommend you to update your password every three months.
3839

3940
## Open a Quickstart template
@@ -46,6 +47,7 @@ Azure QuickStart Templates is a repository for ARM templates. Instead of creatin
4647
```url
4748
https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-simple-windows/azuredeploy.json
4849
```
50+
4951
3. Select **Open** to open the file.
5052
4. Select **File**>**Save As** to save a copy of the file to your local computer with the name **azuredeploy.json**.
5153

@@ -62,33 +64,43 @@ When you explore the template in this section, try to answer these questions:
6264

6365
![Visual Studio Code Azure Resource Manager templates](./media/template-tutorial-create-templates-with-dependent-resources/resource-manager-template-visual-studio-code.png)
6466

65-
There are five resources defined by the template:
67+
There are six resources defined by the template:
6668

67-
* `Microsoft.Storage/storageAccounts`. See the [template reference](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts).
68-
* `Microsoft.Network/publicIPAddresses`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses).
69-
* `Microsoft.Network/virtualNetworks`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/virtualnetworks).
70-
* `Microsoft.Network/networkInterfaces`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/networkinterfaces).
71-
* `Microsoft.Compute/virtualMachines`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.compute/virtualmachines).
69+
* [**Microsoft.Storage/storageAccounts**](/azure/templates/Microsoft.Storage/storageAccounts).
70+
* [**Microsoft.Network/publicIPAddresses**](/azure/templates/microsoft.network/publicipaddresses).
71+
* [**Microsoft.Network/networkSecurityGroups**](/azure/templates/microsoft.network/networksecuritygroups).
72+
* [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks).
73+
* [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkinterfaces).
74+
* [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualmachines).
7275

73-
It is helpful to get some basic understanding of the template before customizing it.
76+
It is helpful to review the template reference before customizing a template.
7477

75-
2. Expand the first resource. It is a storage account. Compare the resource definition to the [template reference](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts).
78+
1. Expand the first resource. It is a storage account. Compare the resource definition to the [template reference](/azure/templates/Microsoft.Storage/storageAccounts).
7679

7780
![Visual Studio Code Azure Resource Manager templates storage account definition](./media/template-tutorial-create-templates-with-dependent-resources/resource-manager-template-storage-account-definition.png)
7881

79-
3. Expand the second resource. The resource type is `Microsoft.Network/publicIPAddresses`. Compare the resource definition to the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses).
82+
1. Expand the second resource. The resource type is `Microsoft.Network/publicIPAddresses`. Compare the resource definition to the [template reference](/azure/templates/microsoft.network/publicipaddresses).
8083

8184
![Visual Studio Code Azure Resource Manager templates public IP address definition](./media/template-tutorial-create-templates-with-dependent-resources/resource-manager-template-public-ip-address-definition.png)
82-
4. Expand the fourth resource. The resource type is `Microsoft.Network/networkInterfaces`:
8385

84-
![Visual Studio Code Azure Resource Manager templates dependsOn](./media/template-tutorial-create-templates-with-dependent-resources/resource-manager-template-visual-studio-code-dependson.png)
86+
1. Expand the third resource. The resource type is `Microsoft.Network/networkSecurityGroups`. Compare the resource definition to the [template reference](/azure/templates/microsoft.network/networksecuritygroups).
87+
88+
![Visual Studio Code Azure Resource Manager templates network security group definition](./media/template-tutorial-create-templates-with-dependent-resources/resource-manager-template-network-security-group-definition.png)
89+
90+
1. Expand the fourth resource. The resource type is `Microsoft.Network/virtualNetworks`:
91+
92+
![Visual Studio Code Azure Resource Manager templates virtual network dependsOn](./media/template-tutorial-create-templates-with-dependent-resources/resource-manager-template-virtual-network-definition.png)
93+
94+
The dependsOn element enables you to define one resource as a dependent on one or more resources. The dependsOn element enables you to define one resource as a dependent on one or more resources. This resource depends on one other resource:
8595

86-
The dependsOn element enables you to define one resource as a dependent on one or more resources. The resource depends on two other resources:
96+
* `Microsoft.Network/networkSecurityGroups`
97+
98+
1. Expand the fifty resource. The resource type is `Microsoft.Network/networkInterfaces`. The resource depends on two other resources:
8799

88100
* `Microsoft.Network/publicIPAddresses`
89101
* `Microsoft.Network/virtualNetworks`
90102

91-
5. Expand the fifth resource. This resource is a virtual machine. It depends on two other resources:
103+
1. Expand the sixth resource. This resource is a virtual machine. It depends on two other resources:
92104

93105
* `Microsoft.Storage/storageAccounts`
94106
* `Microsoft.Network/networkInterfaces`
@@ -101,27 +113,17 @@ By specifying the dependencies, Resource Manager efficiently deploys the solutio
101113

102114
## Deploy the template
103115

104-
[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)]
105-
106-
There are many methods for deploying templates. In this tutorial, you use Cloud Shell from the Azure portal.
107-
108-
1. Sign in to the [Cloud Shell](https://shell.azure.com).
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:
116+
1. 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.
111117

112-
![Azure portal Cloud shell upload file](./media/template-tutorial-create-templates-with-dependent-resources/azure-portal-cloud-shell-upload-file.png)
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.
114-
115-
You can optionally use the **ls $HOME** command and the **cat $HOME/azuredeploy.json** command to verify the files are uploaded successfully.
116-
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).
118+
1. Run the following PowerShell script to deploy the template.
118119

119120
```azurepowershell
120-
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
121+
$projectName = Read-Host -Prompt "Enter a project name that is used to generate resource group name"
121122
$location = Read-Host -Prompt "Enter the location (i.e. centralus)"
122123
$adminUsername = Read-Host -Prompt "Enter the virtual machine admin username"
123124
$adminPassword = Read-Host -Prompt "Enter the admin password" -AsSecureString
124125
$dnsLabelPrefix = Read-Host -Prompt "Enter the DNS label prefix"
126+
$resourceGroupName = "${projectName}rg"
125127

126128
New-AzResourceGroup -Name $resourceGroupName -Location "$location"
127129
New-AzResourceGroupDeployment `
@@ -136,8 +138,11 @@ There are many methods for deploying templates. In this tutorial, you use Cloud
136138
1. Run the following PowerShell command to list the newly created virtual machine:
137139

138140
```azurepowershell
139-
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
140-
Get-AzVM -Name SimpleWinVM -ResourceGroupName $resourceGroupName
141+
$projectName = Read-Host -Prompt "Enter a project name that is used to generate resource group name"
142+
$resourceGroupName = "${projectName}rg"
143+
$vmName = "SimpleWinVM"
144+
145+
Get-AzVM -Name $vmName -ResourceGroupName $resourceGroupName
141146
Write-Host "Press [ENTER] to continue ..."
142147
```
143148

0 commit comments

Comments
 (0)