Skip to content

Commit 8aea57b

Browse files
authored
Merge pull request #97723 from tfitzmac/1203depends
clarified conditional with dependsOn
2 parents e68b2a5 + 9b4b7b6 commit 8aea57b

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

articles/azure-resource-manager/conditional-resource-deployment.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Conditional deployment with templates
33
description: Describes how to conditionally deploy a resource in an Azure Resource Manager template.
44
ms.topic: conceptual
5-
ms.date: 09/03/2019
5+
ms.date: 12/03/2019
66
---
77

88
# Conditional deployment in Resource Manager templates
@@ -74,6 +74,8 @@ If you use a [reference](resource-group-template-functions-resource.md#reference
7474

7575
Use the [if](resource-group-template-functions-logical.md#if) function to make sure the function is only evaluated for conditions when the resource is deployed. See the [if function](resource-group-template-functions-logical.md#if) for a sample template that uses if and reference with a conditionally deployed resource.
7676

77+
You set a [resource as dependent](resource-group-define-dependencies.md) on a conditional resource exactly as you would any other resource. When a conditional resource isn't deployed, Azure Resource Manager automatically removes it from the required dependencies.
78+
7779
## Condition with complete mode
7880

7981
If you deploy a template with [complete mode](deployment-modes.md) and a resource isn't deployed because condition evaluates to false, the result depends on which REST API version you use to deploy the template. If you use a version earlier than 2019-05-10, the resource **isn't deleted**. With 2019-05-10 or later, the resource **is deleted**. The latest versions of Azure PowerShell and Azure CLI delete the resource when condition is false.

articles/azure-resource-manager/resource-group-define-dependencies.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
title: Set deployment order for resources
33
description: Describes how to set one resource as dependent on another resource during deployment to ensure resources are deployed in the correct order.
44
ms.topic: conceptual
5-
ms.date: 03/20/2019
5+
ms.date: 12/03/2019
66
---
7-
# Define the order for deploying resources in Azure Resource Manager Templates
7+
# Define the order for deploying resources in Azure Resource Manager templates
88

9-
For a given resource, there can be other resources that must exist before the resource is deployed. For example, a SQL server must exist before attempting to deploy a SQL database. You define this relationship by marking one resource as dependent on the other resource. You define a dependency with the **dependsOn** element, or by using the **reference** function.
9+
When deploying a resource, you may need to make sure other resources exist before it's deployed. For example, you need a SQL server before deploying a SQL database. You define this relationship by marking one resource as dependent on the other resource. You define a dependency with the **dependsOn** element, or by using the **reference** function.
1010

11-
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. You only need to define dependencies for resources that are deployed in the same template.
12-
13-
For a tutorial, see [Tutorial: create Azure Resource Manager templates with dependent resources](./resource-manager-tutorial-create-templates-with-dependent-resources.md).
11+
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. You only need to define dependencies for resources that are deployed in the same template.
1412

1513
## dependsOn
1614

17-
Within your template, the dependsOn element enables you to define one resource as a dependent on one or more resources. Its value can be a comma-separated list of resource names.
15+
Within your template, the dependsOn element enables you to define one resource as a dependent on one or more resources. Its value is a comma-separated list of resource names. The list can include resources that are [conditionally deployed](conditional-resource-deployment.md). When a conditional resource isn't deployed, Azure Resource Manager automatically removes it from the required dependencies.
1816

1917
The following example shows a virtual machine scale set that depends on a load balancer, virtual network, and a loop that creates multiple storage accounts. These other resources aren't shown in the following example, but they would need to exist elsewhere in the template.
2018

@@ -45,12 +43,13 @@ When defining dependencies, you can include the resource provider namespace and
4543
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
4644
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
4745
]
48-
```
46+
```
4947

50-
While you may be inclined to use dependsOn to map relationships between your resources, it's important to understand why you're doing it. For example, to document how resources are interconnected, dependsOn isn't the right approach. You can't query which resources were defined in the dependsOn element after deployment. By using dependsOn, you potentially impact deployment time because Resource Manager doesn't deploy in parallel two resources that have a dependency.
48+
While you may be inclined to use dependsOn to map relationships between your resources, it's important to understand why you're doing it. For example, to document how resources are interconnected, dependsOn isn't the right approach. You can't query which resources were defined in the dependsOn element after deployment. By using dependsOn, you potentially impact deployment time because Resource Manager doesn't deploy in parallel two resources that have a dependency.
5149

5250
## Child resources
53-
The resources property allows you to specify child resources that are related to the resource being defined. Child resources can only be defined five levels deep. It's important to note that an implicit deployment dependency isn't created between a child resource and the parent resource. If you need the child resource to be deployed after the parent resource, you must explicitly state that dependency with the dependsOn property.
51+
52+
The resources property allows you to specify child resources that are related to the resource being defined. Child resources can only be defined five levels deep. It's important to note that an implicit deployment dependency isn't created between a child resource and the parent resource. If you need the child resource to be deployed after the parent resource, you must explicitly state that dependency with the dependsOn property.
5453

5554
Each parent resource accepts only certain resource types as child resources. The accepted resource types are specified in the [template schema](https://github.com/Azure/azure-resource-manager-schemas) of the parent resource. The name of child resource type includes the name of the parent resource type, such as **Microsoft.Web/sites/config** and **Microsoft.Web/sites/extensions** are both child resources of the **Microsoft.Web/sites**.
5655

@@ -95,6 +94,7 @@ The following example shows a SQL server and SQL database. Notice that an explic
9594
```
9695

9796
## reference and list functions
97+
9898
The [reference function](resource-group-template-functions-resource.md#reference) enables an expression to derive its value from other JSON name and value pairs or runtime resources. The [list* functions](resource-group-template-functions-resource.md#list) return values for a resource from a list operation. Reference and list expressions implicitly declare that one resource depends on another, when the referenced resource is deployed in the same template and referred to by its name (not resource ID). If you pass the resource ID into the reference or list functions, an implicit reference isn't created.
9999

100100
The general format of the reference function is:

0 commit comments

Comments
 (0)