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
Your R&D team asked you to deploy an Azure SQL database so they can compare it to Azure Cosmos DB.
20
-
An SQL database is a child resource of the Azure SQL logical server resource.
21
-
Which of these statements is true?
22
-
choices:
23
-
- content: The SQL database resource might be in a different resource provider than its parent.
24
-
isCorrect: false
25
-
explanation: Incorrect. Child resources always exist within the same resource provider as their parent. Extension resources might exist in different resource providers.
26
-
- content: You can use the `parent` property to tell Bicep about the relationship between the parent and child resources.
27
-
isCorrect: true
28
-
explanation: Correct. In Bicep, you define child resources by using the `parent` property, by using nested resources, or by constructing a child resource name directly.
29
-
- content: An Azure SQL logical server instance is an implicit resource.
30
-
isCorrect: false
31
-
explanation: Incorrect. You need to explicitly deploy a logical server instance. It's not an implicit resource.
32
-
- content: |
33
-
You're asked to deploy an extension resource with the type: `Microsoft.Authorization/roleAssignments`.
34
-
Which of these approaches should you consider?
35
-
choices:
36
-
- content: Use the `scope` property on a resource definition.
37
-
isCorrect: true
38
-
explanation: Correct. In Bicep, you define an extension resource by using the `scope` keyword.
39
-
- content: Use the `parent` property on a resource definition.
40
-
isCorrect: false
41
-
explanation: Incorrect. You can define child resources by using the `parent` keyword, but this keyword isn't applicable to extension resources.
42
-
- content: Use a nested resource declaration.
43
-
isCorrect: false
44
-
explanation: Incorrect. You can define child resources by using a nested resource definition, but you can't define extension resources in this way.
45
-
- content: Which of these statements is true?
46
-
choices:
47
-
- content: Using the `existing` keyword on a resource declaration means that Bicep redeploys the resource.
48
-
isCorrect: false
49
-
explanation: Incorrect. The `existing` keyword means that Bicep doesn't attempt to deploy the resource. Use the keyword to refer to the resource within your Bicep template.
50
-
- content: All resource definitions in a Bicep file need to have a SKU property set, even existing resources.
51
-
isCorrect: false
52
-
explanation: Incorrect. When you define a resource by using the `existing` keyword, you don't specify the SKU property or most other properties.
53
-
- content: You can access the properties of existing resources by using the resource's symbolic name.
54
-
isCorrect: true
55
-
explanation: Correct. You can use an existing resource to access its properties, including secrets that the resource exposes.
Your R&D team asked you to deploy an Azure SQL database so they can compare it to Azure Cosmos DB.
20
+
An SQL database is a child resource of the Azure SQL logical server resource.
21
+
Which of these statements is true?
22
+
choices:
23
+
- content: The SQL database resource might be in a different resource provider than its parent.
24
+
isCorrect: false
25
+
explanation: Incorrect. Child resources always exist in the same resource provider as their parent. Extension resources might exist in different resource providers.
26
+
- content: You can use the `parent` property to inform Bicep about the relationship between the parent and child resources.
27
+
isCorrect: true
28
+
explanation: Correct. In Bicep, you define child resources by using the `parent` property, by using nested resources, or by constructing a child resource name directly.
29
+
- content: An Azure SQL logical server instance is an implicit resource.
30
+
isCorrect: false
31
+
explanation: Incorrect. You need to explicitly deploy a logical server instance. It's not an implicit resource.
32
+
- content: |
33
+
You're asked to deploy an extension resource with the type `Microsoft.Authorization/roleAssignments`.
34
+
Which of these approaches should you consider?
35
+
choices:
36
+
- content: Use the `scope` property on a resource definition.
37
+
isCorrect: true
38
+
explanation: Correct. In Bicep, you define an extension resource by using the `scope` keyword.
39
+
- content: Use the `parent` property on a resource definition.
40
+
isCorrect: false
41
+
explanation: Incorrect. You can define child resources by using the `parent` keyword, but this keyword isn't applicable to extension resources.
42
+
- content: Use a nested resource declaration.
43
+
isCorrect: false
44
+
explanation: Incorrect. You can define child resources by using a nested resource definition, but you can't define extension resources in this way.
45
+
- content: Which of these statements is true?
46
+
choices:
47
+
- content: Using the `existing` keyword on a resource declaration means that Bicep redeploys the resource.
48
+
isCorrect: false
49
+
explanation: Incorrect. The `existing` keyword means that Bicep doesn't attempt to deploy the resource. Use the keyword to refer to the resource within your Bicep template.
50
+
- content: All resource definitions in a Bicep file need to have an SKU property set, even existing resources.
51
+
isCorrect: false
52
+
explanation: Incorrect. When you define a resource by using the `existing` keyword, you don't need to specify the SKU property or most other properties.
53
+
- content: You can access the properties of existing resources by using the resource's symbolic name.
54
+
isCorrect: true
55
+
explanation: Correct. You can use an existing resource to access its properties, including secrets that the resource exposes.
Copy file name to clipboardExpand all lines: learn-pr/azure/child-extension-bicep-templates/includes/6-work-with-existing-resources.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Let's look closely at what makes up this definition:
25
25
> [!NOTE]
26
26
> Remember, the symbolic name is used only in the current Bicep file. If you create this resource by using one Bicep file and refer to it by using the `existing` resource in a different Bicep file, the symbolic names don't have to match.
27
27
28
-
- The `existing` keyword indicates to Bicep that the resource definition is a reference to a resource that's arleady created, and that Bicep shouldn't try to deploy it.
28
+
- The `existing` keyword indicates to Bicep that the resource definition is a reference to a resource that's already created, and that Bicep shouldn't try to deploy it.
29
29
- The `name` property is the Azure resource name of the storage account that was previously deployed.
30
30
- You don't need to specify the `location`, `sku`, or `properties` because the template doesn't deploy the resource. It just references an existing resource. Think of it as a placeholder resource.
31
31
@@ -61,7 +61,7 @@ Now that you understand how to refer to existing resources, let's look at how yo
61
61
62
62
## Add child and extension resources to an existing resource
63
63
64
-
You can add a child resource to an already-created parent resource by using a combination of the `existing` keyword and the `parent` keyword. The following example template creates an Azure SQL database within a server that already exists:
64
+
You can add a child resource to an existing parent resource by using a combination of the `existing` keyword and the `parent` keyword. The following example template creates an Azure SQL database in a server that already exists:
@@ -71,26 +71,26 @@ If you need to deploy an extension resource to an existing resource, you can use
71
71
72
72
## Refer to an existing resource's properties
73
73
74
-
Resources often need to refer to the properties of other resources. For example, if you deploy an application, it might need to know the keys or connection information for another resource. By using the `existing` keyword, you get access to the properties of the resource that you're referring to.
74
+
Resources often need to refer to the properties of other resources. For example, if you deploy an application, it might need to know the keys or connection information for another resource. You can use the `existing` keyword to get access to the properties of the resource that you're referring to.
75
75
76
76
> [!TIP]
77
-
> It's a best practice to look up keys from other resources in this way instead of passing them around through outputs. You'll always get the most up-to-date data. Also, importantly, outputs are not designed to handle secure data such as keys.
77
+
> It's a best practice to look up keys from other resources in this way instead of passing them around through outputs. You'll always get the most up-to-date data. Also, it's important to note that outputs aren't designed to handle secure data like keys.
78
78
79
-
The way that you access the information about a resource depends on the type of information you're getting. If it's a property that isn't secure, you ordinarily use only the `properties` of the resource. The following example template deploys an Azure Functions application, and uses the access details (*instrumentation key*) for an Application Insights instance that was already created:
79
+
The way that you access the information about a resource depends on the type of information you're getting. If it's a property that isn't secure, you ordinarily use only the `properties` of the resource. The following example template deploys an Azure Functions application and uses the access details (*instrumentation key*) for an existing Application Insights instance:
In this example, because the instrumentation key isn't considered sensitive data, it's available in the `properties` of the resource. When you need to access secure data, such as the credentials to use to access a resource, use the `listKeys()` function, as shown in the following code:
Notice that the `listKeys` function returns a `keys` array. The Bicep code retrieves the `value` property from the first item in the `keys` array. Each resource type has different information available from the `listKeys()` function. The Bicep extension for Visual Studio Code gives you hints to help you to understand the data that each resource's `listKeys()` function returns. The following screenshot shows the `listKeys()` function's output for a storage account:
87
+
Notice that the `listKeys` function returns a `keys` array. The Bicep code retrieves the `value` property from the first item in the `keys` array. For each resource type, different information is available from the `listKeys()` function. The Bicep extension for Visual Studio Code gives you hints to help you to understand the data that each resource's `listKeys()` function returns. The following screenshot shows the `listKeys()` function's output for a storage account:
88
88
89
-
:::image type="content" source="../media/6-code-hint-listkeys-storage.png" alt-text="Screenshot of the Bicep extension for Visual Studio Code. IntelliSense displays several the information returned by the listKeys function for a storage account." border="true":::
89
+
:::image type="content" source="../media/6-code-hint-listkeys-storage.png" alt-text="Screenshot of the Bicep extension for Visual Studio Code. IntelliSense displays the information returned by the listKeys function for a storage account." border="true" lightbox="../media/6-code-hint-listkeys-storage.png":::
90
90
91
-
Some resources support other functions, too. Visual Studio Code's IntelliSense lists the functions available for each resource. In the following screenshot, you can see that storage accounts provide functions named `listAccountSas()` and `listServiceSas()` in addition to `listKeys()`:
91
+
Some resources also support other functions. Visual Studio Code IntelliSense lists the functions available for each resource. In the following screenshot, you can see that storage accounts provide functions named `listAccountSas()` and `listServiceSas()` in addition to `listKeys()`:
92
92
93
-
:::image type="content" source="../media/6-code-hint-functions.png" alt-text="Screenshot of the Bicep extension for Visual Studio Code. IntelliSense displays several functions available for the storage account." border="true":::
93
+
:::image type="content" source="../media/6-code-hint-functions.png" alt-text="Screenshot of the Bicep extension for Visual Studio Code. IntelliSense displays several functions available for a storage account." border="true" lightbox="../media/6-code-hint-functions.png":::
94
94
95
95
> [!IMPORTANT]
96
96
> The `listKeys()` function provides access to sensitive data about the resource. This means that the user or service principal that runs the deployment needs to have the appropriate level of permission on the resource. This is usually the *Contributor* built-in role, or a custom role that assigns the appropriate permission.
0 commit comments