Skip to content

Commit 6b98536

Browse files
author
gitName
committed
AB#1055041: Create composable Bicep files by using modules
1 parent 0899c45 commit 6b98536

12 files changed

+205
-205
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.create-composable-bicep-files-using-modules.introduction
3-
title: Introduction
4-
metadata:
5-
unitType: introduction
6-
title: Introduction
7-
description: Introduction to creating composable Bicep files by using modules.
8-
ms.date: 01/31/2025
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
durationInMinutes: 2
15-
content: |
16-
[!include[](includes/1-introduction.md)]
17-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.create-composable-bicep-files-using-modules.introduction
3+
title: Introduction
4+
metadata:
5+
unitType: introduction
6+
title: Introduction
7+
description: Introduction to creating composable Bicep files by using modules.
8+
ms.date: 05/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
durationInMinutes: 2
15+
content: |
16+
[!include[](includes/1-introduction.md)]
17+
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.create-composable-bicep-files-using-modules.create-use-bicep-modules
3-
title: Create and use Bicep modules
4-
metadata:
5-
unitType: learning-content
6-
title: Create and use Bicep modules
7-
description: Learn about the benefits of Bicep modules, and the basic syntax to create and use modules. Also, learn how modules relate to Azure deployments.
8-
ms.date: 01/31/2025
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
durationInMinutes: 10
15-
content: |
16-
[!include[](includes/2-create-use-bicep-modules.md)]
17-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.create-composable-bicep-files-using-modules.create-use-bicep-modules
3+
title: Create and use Bicep modules
4+
metadata:
5+
unitType: learning-content
6+
title: Create and use Bicep modules
7+
description: Learn about the benefits of Bicep modules, and the basic syntax to create and use modules. Also, learn how modules relate to Azure deployments.
8+
ms.date: 05/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
durationInMinutes: 10
15+
content: |
16+
[!include[](includes/2-create-use-bicep-modules.md)]
17+
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.create-composable-bicep-files-using-modules.add-parameters-outputs-modules
3-
title: Add parameters and outputs to modules
4-
metadata:
5-
unitType: learning-content
6-
title: Add parameters and outputs to modules
7-
description: Learn how to plan the parameters and outputs of your Bicep modules.
8-
ms.date: 01/31/2025
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
durationInMinutes: 7
15-
content: |
16-
[!include[](includes/3-add-parameters-outputs-modules.md)]
17-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.create-composable-bicep-files-using-modules.add-parameters-outputs-modules
3+
title: Add parameters and outputs to modules
4+
metadata:
5+
unitType: learning-content
6+
title: Add parameters and outputs to modules
7+
description: Learn how to plan the parameters and outputs of your Bicep modules.
8+
ms.date: 05/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
durationInMinutes: 7
15+
content: |
16+
[!include[](includes/3-add-parameters-outputs-modules.md)]
17+
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.create-composable-bicep-files-using-modules.exercise-create-use-module
3-
title: Exercise - Create and use a module
4-
sandbox: true
5-
metadata:
6-
unitType: exercise
7-
title: Exercise - Create and use a module
8-
description: Create a set of Bicep modules and a template that uses them.
9-
ms.date: 01/31/2025
10-
author: mumian
11-
ms.author: jgao
12-
ms.topic: unit
13-
ms.custom: devx-track-bicep
14-
zone_pivot_groups: azure-shell-interface
15-
durationInMinutes: 9
16-
content: |
17-
[!include[](includes/4-exercise-create-use-module.md)]
18-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.create-composable-bicep-files-using-modules.exercise-create-use-module
3+
title: Exercise - Create and use a module
4+
sandbox: true
5+
metadata:
6+
unitType: exercise
7+
title: Exercise - Create and use a module
8+
description: Create a set of Bicep modules and a template that uses them.
9+
ms.date: 05/22/2025
10+
author: mumian
11+
ms.author: jgao
12+
ms.topic: unit
13+
ms.custom: devx-track-bicep
14+
zone_pivot_groups: azure-shell-interface
15+
durationInMinutes: 9
16+
content: |
17+
[!include[](includes/4-exercise-create-use-module.md)]
18+
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.create-composable-bicep-files-using-modules.knowledge-check
3-
title: Module assessment
4-
metadata:
5-
unitType: knowledge_check
6-
title: Module assessment
7-
description: Check your knowledge.
8-
ms.date: 01/31/2025
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
durationInMinutes: 3
15-
content: |
16-
[!include[](includes/5-knowledge-check.md)]
17-
quiz:
18-
questions:
19-
- content: You deploy the *main.bicep* file with the default settings. You open the Azure portal and look at the deployment history for the resource group. What do you see?
20-
choices:
21-
- content: A single deployment named `main`.
22-
isCorrect: false
23-
explanation: Incorrect. Azure creates a deployment resource for each module, along with the template that you deploy.
24-
- content: Two deployments. One is named `main` and the other is named `storage1`.
25-
isCorrect: false
26-
explanation: Incorrect. Although Azure creates two deployments in this example, the `name` property sets the module's deployment name, not the symbolic name.
27-
- content: Two deployments. One is named `main` and the other is named `my-storage`.
28-
isCorrect: true
29-
explanation: Correct. Azure creates two deployments in this example. By default, the template file name is used for the parent deployment's name. The `name` property sets the module deployment's name.
30-
- content: You plan to update the *main.bicep* file to add another resource. The new resource needs access to the key of the storage account created in the module. What should you do?
31-
choices:
32-
- content: Create an output in the module and set its value to the storage account's connection string.
33-
isCorrect: false
34-
explanation: Incorrect. Outputs should not be used for secure data, because they're logged and might be accessible to a lot of people in your organization.
35-
- content: Use a key vault to create a secret.
36-
isCorrect: true
37-
explanation: Correct. You can define a key vault secret for the connection string value. Alternatively, you can use the `existing` keyword to read the properties of the storage account in another Bicep file.
38-
- content: You don't need to do anything. Properties for all the resources defined in the module are automatically available to the parent template.
39-
isCorrect: false
40-
explanation: Incorrect. Properties for resources are accessible only within the Bicep file where they're declared.
41-
- content: Your colleague has created a large Bicep file that you want to decompose into modules. You want to identify the resources that should be defined together in each module. Which tool can you consider using to help you achieve this task?
42-
choices:
43-
- content: Use the Bicep visualizer.
44-
isCorrect: true
45-
explanation: Correct. The Bicep visualizer illustrates the relationships between your resources. It can help you see any resources that are tightly coupled, which might indicate that they should be in a module together.
46-
- content: Use the Bicep linter.
47-
isCorrect: false
48-
explanation: Incorrect. The Bicep linter scans your Bicep code for potential problems and warns you when you're not following best practices.
49-
- content: Use the Azure documentation for ARM templates.
50-
isCorrect: false
51-
explanation: Incorrect. Although the ARM template documentation can be useful, it's not likely to help you when you're trying to decide how to decompose a Bicep file into modules.
52-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.create-composable-bicep-files-using-modules.knowledge-check
3+
title: Module assessment
4+
metadata:
5+
unitType: knowledge_check
6+
title: Module assessment
7+
description: Check your knowledge.
8+
ms.date: 05/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
durationInMinutes: 3
15+
content: |
16+
[!include[](includes/5-knowledge-check.md)]
17+
quiz:
18+
questions:
19+
- content: You deploy the *main.bicep* file with the default settings, then open the Azure portal and look at the deployment history for the resource group. What do you see?
20+
choices:
21+
- content: A single deployment named `main`.
22+
isCorrect: false
23+
explanation: Incorrect. Azure creates a deployment resource for each module, along with the template that you deploy.
24+
- content: "Two deployments: one is named `main` and the other is named `storage1`."
25+
isCorrect: false
26+
explanation: Incorrect. Although Azure creates two deployments in this example, the `name` property sets the module's deployment name, not the symbolic name.
27+
- content: "Two deployments: one is named `main` and the other is named `my-storage`."
28+
isCorrect: true
29+
explanation: Correct. Azure creates two deployments in this example. By default, the template file name is used for the parent deployment's name. The `name` property sets the module deployment's name.
30+
- content: You plan to update the *main.bicep* file to add another resource. The new resource needs access to the key of the storage account created in the module. What should you do?
31+
choices:
32+
- content: Create an output in the module and set its value to the storage account's connection string.
33+
isCorrect: false
34+
explanation: "Incorrect. You shouldn't use outputs for secure data, because they're logged and might be accessible to many people in your organization."
35+
- content: Use a key vault to create a secret.
36+
isCorrect: true
37+
explanation: Correct. You can define a key vault secret for the connection string value. Alternatively, you can use the `existing` keyword to read the properties of the storage account in another Bicep file.
38+
- content: You don't need to do anything. Properties for all the resources defined in the module are automatically available to the parent template.
39+
isCorrect: false
40+
explanation: Incorrect. Properties for resources are accessible only within the Bicep file in which they're declared.
41+
- content: Your colleague has created a large Bicep file that you want to decompose into modules. You want to identify the resources that should be defined together in each module. Which tool can you consider using to help you achieve this task?
42+
choices:
43+
- content: Use the Bicep visualizer.
44+
isCorrect: true
45+
explanation: Correct. The Bicep visualizer illustrates the relationships between your resources. It can help you see any resources that are tightly coupled, which might indicate that they should be in a module together.
46+
- content: Use the Bicep linter.
47+
isCorrect: false
48+
explanation: Incorrect. The Bicep linter scans your Bicep code for potential problems and warns you when you're not following best practices.
49+
- content: Use the Azure documentation for ARM templates.
50+
isCorrect: false
51+
explanation: Incorrect. Although the ARM template documentation can be useful, it's not likely to help you when you're trying to decide how to decompose a Bicep file into modules.
52+
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
### YamlMime:ModuleUnit
2-
uid: learn.azure.create-composable-bicep-files-using-modules.summary
3-
title: Summary
4-
metadata:
5-
unitType: summary
6-
title: Summary
7-
description: Summary for creating composable Bicep files by using modules.
8-
ms.date: 01/31/2025
9-
author: mumian
10-
ms.author: jgao
11-
ms.topic: unit
12-
ms.custom:
13-
- devx-track-bicep
14-
durationInMinutes: 1
15-
content: |
16-
[!include[](includes/6-summary.md)]
17-
1+
### YamlMime:ModuleUnit
2+
uid: learn.azure.create-composable-bicep-files-using-modules.summary
3+
title: Summary
4+
metadata:
5+
unitType: summary
6+
title: Summary
7+
description: Summary for creating composable Bicep files by using modules.
8+
ms.date: 05/22/2025
9+
author: mumian
10+
ms.author: jgao
11+
ms.topic: unit
12+
ms.custom:
13+
- devx-track-bicep
14+
durationInMinutes: 1
15+
content: |
16+
[!include[](includes/6-summary.md)]
17+

learn-pr/azure/create-composable-bicep-files-using-modules/includes/1-introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To improve performance and reduce cost, you've been asked to add a content deliv
1212

1313
:::image type="content" source="../media/1-architecture-diagram.png" alt-text="Architecture diagram that shows two variants: one with traffic flowing from the internet to the app through a CDN, and another without a CDN." border="false" :::
1414

15-
## What will we be doing?
15+
## What will we learn?
1616

1717
In this module, you'll create a set of Bicep modules to deploy your website and CDN. Then, you'll create a template that uses those modules together.
1818

learn-pr/azure/create-composable-bicep-files-using-modules/includes/2-create-use-bicep-modules.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ By using modules, you can reuse your Bicep code, and you can make your Bicep fil
44

55
## The benefits of modules
66

7-
In your toy company, you've been provisioning cloud resources by using many individual Bicep files. Over time, these templates grow significantly. Eventually, you end up having monolithic code that's difficult to read and navigate, and even harder to maintain.
7+
In your toy company, you've been provisioning cloud resources by using many individual Bicep files. Over time, these templates grow significantly. Eventually, you end up having monolithic code that's difficult to read and navigate and even harder to maintain.
88

99
This approach also forces you to duplicate parts of your code when you want to reuse it in other templates. When you change something, you need to search through and update multiple files.
1010

@@ -22,7 +22,7 @@ You can even share modules within your team, within your organization, or with t
2222

2323
Modules help you keep related resource definitions together. For example, when you define an Azure Functions app, you typically deploy the app, a hosting plan for the app, and a storage account for the app's metadata. These three components are defined separately, but they represent a logical grouping of resources, so it might make sense to define them as a module.
2424

25-
That way, your main template doesn't need to be aware of the details of how a function app is deployed. That's the responsibility of the module.
25+
That way, your main template doesn't need to be aware of the details of how a function app is deployed. That's the module's responsibility.
2626

2727
### Composability
2828

@@ -80,7 +80,7 @@ Be sure to use a descriptive file name for each module. The file name effectivel
8080

8181
## Use the module in a Bicep template
8282

83-
You'll use a module in a Bicep template by using the `module` keyword, like this:
83+
You can use a module in a Bicep template by using the `module` keyword, like this:
8484

8585
```bicep
8686
module appModule 'modules/app.bicep' = {
@@ -125,8 +125,8 @@ You can list and view the details of deployment resources to monitor the status
125125

126126
### Generated JSON ARM templates
127127

128-
When you deploy a Bicep file, Bicep converts it to a JSON ARM template. This conversion is also called _transpilation_. The modules that the template uses are embedded into the JSON file. Regardless of how many modules you include in your template, only a single JSON file will be created.
128+
When you deploy a Bicep file, Bicep converts it to a JSON ARM template. This conversion is also called _transpilation_. The modules that the template uses are embedded into the JSON file. Regardless of how many modules you include in your template, only a single JSON file is created.
129129

130-
In the example discussed in the previous section, Bicep generates a single JSON file even though there were originally two Bicep files.
130+
In the example in the previous section, Bicep generates a single JSON file even though there were originally two Bicep files.
131131

132132
:::image type="content" source="../media/2-transpile.png" alt-text="Diagram that shows two Bicep files, which are transpiled into a single JSON file." border="false":::

learn-pr/azure/create-composable-bicep-files-using-modules/includes/3-add-parameters-outputs-modules.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Think about the parameters that your module accepts, and whether each parameter
1212

1313
When you create parameters for templates, it's a good practice to add default parameters where you can. In modules, it's not always as important to add default parameters, because your module will be used by a parent template that might use its own default parameters. If you have similar parameters in both files, both with default values, it can be hard for your template's users to figure out which default value will be applied and to enforce consistency. It's often better to leave the default value on the parent template and remove it from the module.
1414

15-
You should also think about how you manage parameters that control the SKUs for your resources and other important configuration settings. When you create a standalone Bicep template, it's common to embed business rules into your template. For example: _When I deploy a production environment, the storage account should use the GRS tier_. But modules sometimes present different concerns.
15+
You should also think about how you manage parameters that control the SKUs for your resources and other important configuration settings. When you create a standalone Bicep template, it's common to embed business rules into your template. For example: _When I deploy a production environment, the storage account should use the GRS tier_. However, modules sometimes present different concerns.
1616

1717
If you're building a module that needs to be reusable and flexible, remember that the business rules for each parent template might be different, so it might not make as much sense to embed business rules into generic modules. Consider defining the business rules in your parent template, then explicitly pass module configuration through parameters.
1818

@@ -32,7 +32,7 @@ You could achieve your requirement by adding a condition to the resource definit
3232

3333
::: code language="bicep" source="code/3-cosmos-db-diagnostic-settings.bicep" highlight="1, 7" :::
3434

35-
When you include this module in a Bicep template, you can easily configure it to send the Azure Cosmos DB account logs to Log Analytics by setting a workspace ID. Or, if you don't need logs for the environment that you're deploying, omit the parameter. It has a default value. The module encapsulates the logic required to do the right thing for your requirements.
35+
When you include this module in a Bicep template, you can easily configure it to send the Azure Cosmos DB account logs to Log Analytics by setting a workspace ID. If you don't need logs for the environment that you're deploying, you can omit the parameter. It has a default value. The module encapsulates the logic required to do the right thing for your requirements.
3636

3737
> [!TIP]
3838
> Remember to test that your template is valid for both scenarios; when the `if` statement is evaluated as either `true` or `false`.
@@ -60,7 +60,7 @@ It's common to create a parent Bicep file that composes multiple modules togethe
6060

6161
::: code language="bicep" source="code/3-chained.bicep" highlight="9, 18" :::
6262

63-
In this example, symbolic names are used for the reference between the modules. This reference helps Bicep to automatically understand the relationships between the modules.
63+
In this example, you use symbolic names for the reference between the modules. This reference helps Bicep automatically understand the relationships between the modules.
6464

6565
Because Bicep understands there's a dependency, it deploys the modules in sequence:
6666

learn-pr/azure/create-composable-bicep-files-using-modules/includes/4-exercise-create-use-module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ New-AzResourceGroupDeployment -Name main -TemplateFile main.bicep
152152

153153
1. Select **<rgn>[sandbox resource group name]</rgn>**.
154154

155-
1. On the left menu, select **Deployments**.
155+
1. On the left menu, select **Deployments** under **Settings**.
156156

157157
:::image type="content" source="../media/4-deployments.png" alt-text="Screenshot of the Azure portal that shows the resource group, with the Deployments menu item highlighted." :::
158158

0 commit comments

Comments
 (0)