Skip to content

Commit ac0ba14

Browse files
Merge pull request #208924 from tfitzmac/0823templatespecs
add required permissions for template specs
2 parents 468207a + 38e7a31 commit ac0ba14

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

articles/azure-resource-manager/bicep/template-specs.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
title: Create & deploy template specs in Bicep
33
description: Describes how to create template specs in Bicep and share them with other users in your organization.
44
ms.topic: conceptual
5-
ms.date: 02/01/2022
5+
ms.date: 08/23/2022
66
---
77

88
# Azure Resource Manager template specs in Bicep
99

10-
A template spec is a resource type for storing an Azure Resource Manager template (ARM template) for later deployment. This resource type enables you to share ARM templates with other users in your organization. Just like any other Azure resource, you can use Azure role-based access control (Azure RBAC) to share the template spec. You can use Azure CLI or Azure PowerShell to create template specs by providing Bicep files. The Bicep files are transpiled into ARM JSON templates before they are stored. Currently, you can't import a Bicep file from the Azure portal to create a template spec resource.
10+
A template spec is a resource type for storing an Azure Resource Manager template (ARM template) for later deployment. This resource type enables you to share ARM templates with other users in your organization. Just like any other Azure resource, you can use Azure role-based access control (Azure RBAC) to share the template spec. You can use Azure CLI or Azure PowerShell to create template specs by providing Bicep files. The Bicep files are transpiled into ARM JSON templates before they're stored. Currently, you can't import a Bicep file from the Azure portal to create a template spec resource.
1111

1212
[Microsoft.Resources/templateSpecs](/azure/templates/microsoft.resources/templatespecs) is the resource type for template specs. It consists of a main template and any number of linked templates. Azure securely stores template specs in resource groups. Both the main template and the linked templates must be in JSON. Template Specs support [versioning](#versioning).
1313

@@ -29,6 +29,12 @@ When designing your deployment, always consider the lifecycle of the resources a
2929

3030
To learn more about template specs, and for hands-on guidance, see [Publish libraries of reusable infrastructure code by using template specs](/learn/modules/arm-template-specs).
3131

32+
## Required permissions
33+
34+
To create a template spec, you need **write** access to `Microsoft.Resources/templateSpecs` and `Microsoft.Resources/templateSpecs/versions`.
35+
36+
To deploy a template spec, you need **read** access to `Microsoft.Resources/templateSpecs` and `Microsoft.Resources/templateSpecs/versions`. You also need **write** access to any resources deployed by the template spec, and access to `Microsoft.Resources/deployments/*`.
37+
3238
## Why use template specs?
3339

3440
Template specs provide the following benefits:
@@ -150,7 +156,7 @@ The JSON template embedded in the Bicep file needs to make these changes:
150156
* To access the parameters and variables defined in the Bicep file, you can directly use the parameter names and the variable names. To access the parameters and variables defined in `mainTemplate`, you still need to use the ARM JSON template syntax. For example, **'name': '[parameters(\'storageAccountType\')]'**.
151157
* Use the Bicep syntax to call Bicep functions. For example, **'location': resourceGroup().location**.
152158

153-
The size of a template spec is limited to approximated 2 MB. If a template spec size exceeds the limit, you will get the **TemplateSpecTooLarge** error code. The error message says:
159+
The size of a template spec is limited to approximated 2 MB. If a template spec size exceeds the limit, you'll get the **TemplateSpecTooLarge** error code. The error message says:
154160

155161
```error
156162
The size of the template spec content exceeds the maximum limit. For large template specs with many artifacts, the recommended course of action is to split it into multiple template specs and reference them modularly via TemplateLinks.
@@ -325,7 +331,7 @@ When you create a template spec, you provide a version name for it. As you itera
325331

326332
## Use tags
327333

328-
[Tags](../management/tag-resources.md) help you logically organize your resources. You can add tags to template specs by using Azure PowerShell and Azure CLI:
334+
[Tags](../management/tag-resources.md) help you logically organize your resources. You can add tags to template specs by using Azure PowerShell and Azure CLI. The following example shows how to specify tags when creating the template spec:
329335

330336
# [PowerShell](#tab/azure-powershell)
331337

@@ -353,6 +359,8 @@ az ts create \
353359

354360
---
355361

362+
The next example shows how to apply tags when updating an existing template spec:
363+
356364
# [PowerShell](#tab/azure-powershell)
357365

358366
```azurepowershell
@@ -379,17 +387,15 @@ az ts update \
379387

380388
---
381389

382-
When creating or modifying a template spec with the version parameter specified, but without the tag/tags parameter:
383-
384-
* If the template spec exists and has tags, but the version doesn't exist, the new version inherits the same tags as the existing template spec.
385-
386-
When creating or modifying a template spec with both the tag/tags parameter and the version parameter specified:
387-
388-
* If both the template spec and the version don't exist, the tags are added to both the new template spec and the new version.
389-
* If the template spec exists, but the version doesn't exist, the tags are only added to the new version.
390-
* If both the template spec and the version exist, the tags only apply to the version.
390+
Both the template and its versions can have tags. The tags are applied or inherited depending on the parameters you specify.
391391

392-
When modifying a template with the tag/tags parameter specified but without the version parameter specified, the tags is only added to the template spec.
392+
| Template spec | Version | Version parameter | Tag parameter | Tag values |
393+
| ------------- | ------- | ----------------- | ------------- | --------------- |
394+
| Exists | N/A | Not specified | Specified | applied to the template spec |
395+
| Exists | New | Specified | Not specified | inherited from the template spec to the version |
396+
| New | New | Specified | Specified | applied to both template spec and version |
397+
| Exists | New | Specified | Specified | applied to the version |
398+
| Exists | Exists | Specified | Specified | applied to the version |
393399

394400
## Link to template specs
395401

0 commit comments

Comments
 (0)