You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn-pr/azure/child-extension-bicep-templates/includes/2-understand-azure-resources.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Every Azure resource has a unique resource ID. This ID includes information that
42
42
43
43
Here's a visual representation of the same information:
44
44
45
-
:::image type="content" source="../media/2-resource-id.png" alt-text="Resource ID for a storage account, split with key/value pair on a separate line." border="false":::
45
+
:::image type="content" source="../media/2-resource-id.png" alt-text="Diagram that shows a resource ID for a storage account. Each component of the ID is presented on a separate line." border="false":::
46
46
47
47
You can see that a resource ID contains information about the resource type and the specific resource you deployed. Here's a breakdown of this example resource ID into its components:
Copy file name to clipboardExpand all lines: learn-pr/azure/child-extension-bicep-templates/includes/3-define-child-resources.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,49 +10,49 @@ It makes sense to deploy some resources only within the context of their parent.
10
10
| Azure Cosmos DB containers |`Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers`|
11
11
|||
12
12
13
-
For example, let's consider a storage blob container. A blob container must be deployed into a storage account, and it doesn't make sense for a container to exist outside of a storage account.
13
+
For example, consider a storage blob container. A blob container must be deployed into a storage account, and it doesn't make sense for a container to exist outside of a storage account.
14
14
15
-
Child resource types have longer names with multiple parts to them. A storage blob container has this fully qualified type name: `Microsoft.Storage/storageAccounts/blobServices/containers`. The resource ID for a blob container includes the name of the storage account that contains the container, and the container's name.
15
+
Child resource types have longer names that are made up of multiple parts. A storage blob container has this fully qualified type name: `Microsoft.Storage/storageAccounts/blobServices/containers`. The resource ID for a blob container includes the name of the storage account that contains the container, and the container's name.
16
16
17
17
> [!NOTE]
18
18
> Some child resources might have the same name as other child resource types from different parents. For example, `containers` is a child type of both storage accounts and Azure Cosmos DB databases. The names are the same, but they represent different resources, and their fully qualified type names are different.
19
19
20
20
## How are child resources defined?
21
21
22
-
With Bicep, you can declare child resources in several different ways. Each way has its own advantages, and each is suitable for some situations and not for others. Let's look at each approach.
22
+
With Bicep, you can declare child resources in several ways. Each method has its own advantages, and each is suitable for some situations and not for others. The following sections describe each approach.
23
23
24
24
> [!TIP]
25
-
> All of the following approaches result in the same deployment activities in Azure. You can choose the approach that best fits your needs without having to worry about breaking something. And you can update your template and change the approach you're using.
25
+
> All the following approaches result in the same deployment activities in Azure. You can choose the approach that best fits your needs without having to worry about breaking anything. And you can update your template and change the approach you're using.
26
26
27
27
### Nested resources
28
28
29
-
One approach to defining a child resource is to *nest* the child resource inside the parent. Here's an example of a Bicep template that deploys a virtual machine and a virtual machine extension. A virtual machine extension is a child resource that provides extra behavior for a virtual machine. In this case, the extension runs a custom script on the virtual machine after deployment.
29
+
One approach to defining a child resource is to *nest* the child resource inside the parent. Here's an example of a Bicep template that deploys a virtual machine and a virtual machine extension. A *virtual machine extension* is a child resource that provides extra behavior for a virtual machine. In this case, the extension runs a custom script on the virtual machine after deployment.
Notice that the nested resource has a simpler resource type than normal. Even though the fully qualified type name is `Microsoft.Compute/virtualMachines/extensions`, the nested resource automatically inherits the parent's resource type, so you need to specify only the child resource type, `extensions`.
34
34
35
35
Also notice that there's no API version specified for the nested resource. Bicep assumes that you want to use the same API version as the parent resource, although you can override the API version if you want to.
36
36
37
-
You can refer to a nested resource by using the `::` operator. For example, you could create an output that returns the full resource ID of the extension:
37
+
You can refer to a nested resource by using the `::` operator. For example, you can create an output that returns the full resource ID of the extension:
Nesting resources is a simple way to declare a child resource. Nesting resources also makes the parent-child relationship obvious to anyone reading the template. However, if you have lots of nested resources, or multiple layers of nesting, templates can become harder to read. You can also nest resources only up to five layers deep.
43
+
Nesting resources is a simple way to declare a child resource. Nesting resources also makes the parent-child relationship obvious to anyone reading the template. However, if you have lots of nested resources, or multiple layers of nesting, templates can become harder to read. Also, you can only nest resources up to five layers deep.
44
44
45
45
### Parent property
46
46
47
-
A second approach is to declare the child resource without any nesting. Then, use the `parent` property to tell Bicep about the parent-child relationship:
47
+
A second approach is to declare the child resource without any nesting. Then, use the `parent` property to inform Bicep about the parent-child relationship:
Notice that the child resource uses the `parent` property to refer to the symbolic name of its parent.
52
52
53
-
This approach to referencing the parent is another easy way to declare a child resource. Bicep understands the relationship between parent and child resources, so you don't need to specify the fully qualified resource name or set up a dependency between the resources. The approach also avoids having too much nesting, which can become difficult to read. However, you need to explicitly specify the full resource type and API version each time you define a child resource using the `parent` property.
53
+
This approach to referencing the parent is another easy way to declare a child resource. Bicep understands the relationship between parent and child resources, so you don't need to specify the fully qualified resource name or set up a dependency between the resources. This approach also avoids having too much nesting, which can become difficult to read. However, you need to explicitly specify the full resource type and API version each time you define a child resource by using the `parent` property.
54
54
55
-
To refer to a child resource declared with the `parent` property, use its symbolic name as you would with a normal parent resource:
55
+
To refer to a child resource that's declared with the `parent` property, use its symbolic name as you would with a normal parent resource:
Notice that this example uses string interpolation to append the virtual machine resource `name` property to the child resource name. Bicep understands that there's a dependency between your child and parent resources. You could declare the child resource name by using the `vmName` variable instead. If you do that, though, your deployment could possibly fail because Bicep wouldn't understand that the parent resource needs to be deployed before the child resource:
67
+
Notice that this example uses string interpolation to append the virtual machine resource `name` property to the child resource name. Bicep understands that there's a dependency between your child and parent resources. You could declare the child resource name by using the `vmName` variable instead. If you do that, though, your deployment might fail because Bicep wouldn't understand that the parent resource needs to be deployed before the child resource.
68
68
69
-
To resolve this situation, you could manually tell Bicep about the dependency by using the `dependsOn` keyword, as shown here:
69
+
To resolve this problem, you could manually inform Bicep about the dependency by using the `dependsOn` keyword, as shown here:
> It's generally best to avoid constructing resource names, because you lose a lot of the benefits that Bicep can provide when it understands the relationships between your resources. Use this option only when you can't use one of the other approaches for declaring child resources.
74
+
> It's generally best to avoid constructing resource names because when you do you lose a lot of the benefits that Bicep provides when it understands the relationships between your resources. Use this option only when you can't use one of the other approaches for declaring child resources.
75
75
76
76
## Child resource IDs
77
77
78
-
You start creating a child resource ID by including its parent's resource ID and then appending the child resource type and name. For example, let's consider an Azure Cosmos DB account named `toyrnd`. The Azure Cosmos DB resource provider exposes a type called `databaseAccounts`, which is the parent resource you deploy:
78
+
You start creating a child resource ID by including its parent's resource ID and then appending the child resource type and name. For example, consider an Azure Cosmos DB account named `toyrnd`. The Azure Cosmos DB resource provider exposes a type called `databaseAccounts`, which is the parent resource you deploy:
Here's a visual depiction of the same resource ID:
85
85
86
-
:::image type="content" source="../media/3-parent-resource-id.png" alt-text="Resource ID for an Azure Cosmos DB account, split with the key-value pair on a separate line." border="false":::
86
+
:::image type="content" source="../media/3-parent-resource-id.png" alt-text="Diagram that shows a resource ID for an Azure Cosmos DB account. Each of the four elements of the ID is presented on a separate line." border="false":::
87
87
88
-
If we add a database to this account, we can use the `sqlDatabases` child resource type. Let's add a database named `FlightTests` to our Azure Cosmos DB account and take a look at the child resource ID:
88
+
If you add a database to this account, you can use the `sqlDatabases` child resource type. Say you add a database named `FlightTests` to the Azure Cosmos DB account. Here's the child resource ID:
:::image type="content" source="../media/3-child-resource-id.png" alt-text="Child resource ID for an Azure Cosmos DB database, split with the key-value pair on a separate line." border="false":::
96
+
:::image type="content" source="../media/3-child-resource-id.png" alt-text="Diagram that shows a child resource ID for an Azure Cosmos DB database. Each of the five elements of the ID is presented on a separate line." border="false":::
97
97
98
98
You can have multiple levels of child resources. Here's an example resource ID that shows a storage account with two levels of children:
Here's a visual representation of the same resource ID:
105
105
106
-
:::image type="content" source="../media/3-storage-child-resource-id.png" alt-text="Child resource ID for a storage account with blob container, split with the key-value pair on a separate line." border="false":::
106
+
:::image type="content" source="../media/3-storage-child-resource-id.png" alt-text="Diagram that shows a child resource ID for a storage account with blob container. The elements are presented on separate lines." border="false":::
107
107
108
-
This resource ID has several components to it:
108
+
This resource ID has several components:
109
109
110
110
- Everything up to `secrettoys` is the parent resource ID.
111
111
112
112
-`blobServices` indicates that the resource is within a child resource type called `blobServices`.
113
113
114
114
> [!NOTE]
115
-
> You don't have to create `blobServices` resources yourself. The `Microsoft.Storage` resource provider automatically creates this resource for you when you create a storage account. This type of resource is sometimes called an *implicit* resource. They're fairly uncommon, but you will find them throughout Azure.
115
+
> You don't have to create `blobServices` resources yourself. The `Microsoft.Storage` resource provider automatically creates this resource when you create a storage account. This type of resource is sometimes called an *implicit* resource. They're fairly uncommon, but you can find them throughout Azure.
116
116
117
117
-`default` is the name of the `blobServices` child resource.
118
118
119
119
> [!NOTE]
120
-
> Sometimes, only a single instance of a child resource is allowed. This type of instance is called a *singleton*, and it's often given the name `default`.
120
+
> Sometimes only a single instance of a child resource is allowed. This type of instance is called a *singleton*, and it's often given the name `default`.
121
121
122
122
-`containers` indicates that the resource is within a child resource type called `containers`.
0 commit comments