|
2 | 2 | title: Bicep modules
|
3 | 3 | description: Describes how to define a module in a Bicep file, and how to use module scopes.
|
4 | 4 | ms.topic: conceptual
|
5 |
| -ms.date: 11/12/2021 |
| 5 | +ms.date: 11/19/2021 |
6 | 6 | ---
|
7 | 7 |
|
8 | 8 | # Bicep modules
|
9 | 9 |
|
10 | 10 | Bicep enables you to organize deployments into modules. A module is just a Bicep file that is deployed from another Bicep file. With modules, you improve the readability of your Bicep files by encapsulating complex details of your deployment. You can also easily reuse modules for different deployments.
|
11 | 11 |
|
12 |
| -To share modules with other people in your organization, [create a private registry](private-module-registry.md). Modules in the registry are only available to users with the correct permissions. |
| 12 | +To share modules with other people in your organization, create a [template spec](../templates/template-specs.md) or [private registry](private-module-registry.md). Template specs and modules in the registry are only available to users with the correct permissions. |
| 13 | + |
| 14 | +> [!TIP] |
| 15 | +> The choice between template specs and private registries is mostly a matter of preference. If you're deploying templates or Bicep files without other project artifacts, template specs are an easier option. If you're deploying project artifacts with the templates or Bicep files, you can integrate the private registry with your development work and then more easily deploy all of it from the registry. |
13 | 16 |
|
14 | 17 | Bicep modules are converted into a single Azure Resource Manager template with [nested templates](../templates/linked-templates.md#nested-template).
|
15 | 18 |
|
@@ -58,7 +61,7 @@ Like resources, modules are deployed in parallel unless they depend on other mod
|
58 | 61 |
|
59 | 62 | ## Path to module
|
60 | 63 |
|
61 |
| -The file for the module can be either a local file or an external file in a Bicep module registry. Both options are shown below. |
| 64 | +The file for the module can be either a local file or an external file. The external file can be in template spec or a Bicep module registry. All fo these options are shown below. |
62 | 65 |
|
63 | 66 | ### Local file
|
64 | 67 |
|
@@ -90,6 +93,31 @@ The full path for a module in a registry can be long. Instead of providing the f
|
90 | 93 |
|
91 | 94 | ::: code language="bicep" source="~/azure-docs-bicep-samples/syntax-samples/modules/alias-definition.bicep" highlight="1" :::
|
92 | 95 |
|
| 96 | +### File in template spec |
| 97 | + |
| 98 | +After creating a [template spec](../templates/template-specs.md), you can link to that template spec in a module. Specify the template spec in the following format: |
| 99 | + |
| 100 | +```bicep |
| 101 | +module <symbolic-name> 'ts:<sub-id>/<rg-name>/<template-spec-name>:<version>' = { |
| 102 | +``` |
| 103 | + |
| 104 | +However, you can simplify your Bicep file by [creating an alias](bicep-config-modules.md) for the resource group that contains your template specs. When using an alias, the syntax becomes: |
| 105 | + |
| 106 | +```bicep |
| 107 | +module <symbolic-name> 'ts/<alias>:<template-spec-name>:<version>' = { |
| 108 | +``` |
| 109 | + |
| 110 | +The following module deploys a template spec to create a storage account. The subscription and resource group for the template spec is defined in the alias named **ContosoSpecs**. |
| 111 | + |
| 112 | +```bicep |
| 113 | +module stgModule 'ts/ContosoSpecs:storageSpec:2.0' = { |
| 114 | + name: 'storageDeploy' |
| 115 | + params: { |
| 116 | + storagePrefix: 'examplestg1' |
| 117 | + } |
| 118 | +} |
| 119 | +``` |
| 120 | + |
93 | 121 | ## Parameters
|
94 | 122 |
|
95 | 123 | The parameters you provide in your module definition match the parameters in the Bicep file.
|
|
0 commit comments