Skip to content

Commit 4df96b2

Browse files
Merge pull request #311079 from mumian/0120-new-directives
Add two new directives
2 parents 6a8dc82 + 07d1de8 commit 4df96b2

3 files changed

Lines changed: 44 additions & 55 deletions

File tree

articles/azure-resource-manager/bicep/bicep-core-diagnostics.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ ms.date: 01/16/2026
1414

1515
If you need more information about a particular diagnostic code, select the **Feedback** button in the upper-right corner of the page and specify the code.
1616

17-
You can suppress Bicep diagnostic codes by using the `disable-next-line` directive. See [`disable-next-line`](./file.md#disable-next-line).
17+
You can suppress Bicep diagnostic codes by using `disable-next-line` and `disable-diagnostics`. See [Directives](./file.md#directives).
18+
1819

1920
| Code | Level | Description |
2021
|------------|-------|-------------|

articles/azure-resource-manager/bicep/file.md

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep file structure and syntax
33
description: Understand how to use declarative syntax to understand the structure and properties of Bicep files.
44
ms.topic: article
55
ms.custom: devx-track-bicep
6-
ms.date: 01/13/2026
6+
ms.date: 01/30/2026
77
---
88

99
# Bicep file structure and syntax
@@ -14,9 +14,9 @@ For a step-by-step tutorial that guides you through the process of creating a Bi
1414

1515
## Known limitations
1616

17-
* Support isn't available for the concept of `apiProfile`, which is used to map a single `apiProfile` to a set `apiVersion` for each resource type.
17+
* The Bicep language doesn't support the concept of `apiProfile`. This concept maps a single `apiProfile` to a set `apiVersion` for each resource type.
1818
* User-defined functions aren't supported at this time. An experimental feature is currently accessible. For more information, see [User-defined functions in Bicep](./user-defined-functions.md).
19-
* Some Bicep features require a corresponding change to the intermediate language (Azure Resource Manager JSON templates). We announce these features as available after all the required updates are deployed to global Azure. If you use a different environment such as Azure Stack, there might be a delay in the availability of the feature. The Bicep feature is available only after the intermediate language is also updated in that environment.
19+
* Some Bicep features require a corresponding change to the intermediate language (Azure Resource Manager JSON templates). The product team announces these features as available after all the required updates are deployed to global Azure. If you use a different environment such as Azure Stack, there might be a delay in the availability of the feature. The Bicep feature is available only after the intermediate language is also updated in that environment.
2020

2121
## Bicep format
2222

@@ -99,11 +99,11 @@ module webModule './webApp.bicep' = {
9999

100100
## Metadata
101101

102-
Metadata in Bicep is an untyped value that you can include in your Bicep files. Metadata provides supplementary information about your Bicep files, like name, description, author, and creation date.
102+
Metadata in Bicep is an untyped value that you can include in your Bicep files. Metadata provides supplementary information about your Bicep files, such as name, description, author, and creation date.
103103

104104
## Target scope
105105

106-
By default, the target scope is set to `resourceGroup`. If you deploy at the resource-group level, you don't need to set the target scope in your Bicep file.
106+
The default target scope is `resourceGroup`. If you deploy at the resource group level, you don't need to set the target scope in your Bicep file.
107107

108108
The allowed values are:
109109

@@ -112,7 +112,7 @@ The allowed values are:
112112
* `managementGroup`: Used for [management group deployments](deploy-to-management-group.md).
113113
* `tenant`: Used for [tenant deployments](deploy-to-tenant.md).
114114

115-
In a module, you can specify a scope that's different than the scope for the rest of the Bicep file. For more information, see [Configure module scope](modules.md#set-module-scope).
115+
In a module, you can specify a scope that's different from the scope for the rest of the Bicep file. For more information, see [Configure module scope](modules.md#set-module-scope).
116116

117117
## Parameters
118118

@@ -138,13 +138,13 @@ For more information, see [Parameters in Bicep](./parameters.md).
138138

139139
## Variables
140140

141-
To make your Bicep file more readable, encapsulate complex expressions in a variable. For example, you might add a variable for a resource name that's constructed by concatenating several values together.
141+
To make your Bicep file more readable, encapsulate complex expressions in a variable. For example, you might add a variable for a resource name that you create by concatenating several values together.
142142

143143
```bicep
144144
var uniqueStorageName = '${storagePrefix}${uniqueString(resourceGroup().id)}'
145145
```
146146

147-
Apply this variable wherever you need the complex expression.
147+
Use this variable wherever you need the complex expression.
148148

149149
```bicep
150150
resource stg 'Microsoft.Storage/storageAccounts@2025-06-01' = {
@@ -157,7 +157,7 @@ For more information, see [Variables in Bicep](./variables.md).
157157

158158
## Resources
159159

160-
Use the `resource` keyword to define a resource to deploy. Your resource declaration includes a symbolic name for the resource. You use this symbolic name in other parts of the Bicep file to get a value from the resource.
160+
Use the `resource` keyword to define a resource to deploy. Your resource declaration includes a symbolic name for the resource. Use this symbolic name in other parts of the Bicep file to get a value from the resource.
161161

162162
The resource declaration includes the resource type and API version. Within the body of the resource declaration, include properties that are specific to the resource type.
163163

@@ -229,7 +229,7 @@ For more information, see [Set name and type for child resources in Bicep](child
229229

230230
## Modules
231231

232-
Modules enable you to reuse code from a Bicep file in other Bicep files. In the module declaration, you link to the file to reuse. When you deploy the Bicep file, the resources in the module are also deployed.
232+
Modules enable you to reuse code from a Bicep file in other Bicep files. In the module declaration, you link to the file to reuse. When you deploy the Bicep file, you also deploy the resources in the module.
233233

234234
```bicep
235235
module webModule './webApp.bicep' = {
@@ -261,7 +261,7 @@ For more information, see [Outputs in Bicep](./outputs.md).
261261

262262
## Types
263263

264-
You can use the `type` statement to define user-defined data types.
264+
Use the `type` statement to define user-defined data types.
265265

266266
```bicep
267267
param location string = resourceGroup().location
@@ -294,7 +294,7 @@ For more information, see [User-defined data types in Bicep](./user-defined-data
294294

295295
## Functions
296296

297-
In your Bicep file, you can create your own functions and also use the [standard Bicep functions](./bicep-functions.md) that are automatically available within your Bicep files. Create your own functions when you have complicated expressions that are used repeatedly in your Bicep files.
297+
In your Bicep file, you can create your own functions and also use the [standard Bicep functions](./bicep-functions.md) that are automatically available within your Bicep files. Create your own functions when you have complicated expressions that you use repeatedly in your Bicep files.
298298

299299
```bicep
300300
func buildUrl(https bool, hostname string, path string) string => '${https ? 'https' : 'http'}://${hostname}${empty(path) ? '' : '/${path}'}'
@@ -306,7 +306,7 @@ For more information, see [User-defined functions in Bicep](./user-defined-funct
306306

307307
## Decorators
308308

309-
You can add one or more decorators for each of the following elements:
309+
Add one or more decorators to each of the following elements:
310310

311311
* [param](#parameters)
312312
* [var](#variables)
@@ -335,44 +335,42 @@ The following table lists the decorators:
335335

336336
## Directives
337337

338-
Directives provide instructions to the Bicep compiler and linter without affecting the runtime behavior of a template. You write directives as comments. The compiler evaluates them during compilation and validation.
339-
340-
A directive uses the following general syntax:
338+
Bicep supports directives (pragmas) to control certain behaviors within the file, such as suppressing linter warnings or warning diagnostic messages. Directives are prefixed with the `#` character.
341339

342340
```bicep
343341
#<directive-name> <argument1> [<argument2> ... ]
344342
```
345343

346-
You separate arguments by using spaces. The specific directive determines how to interpret the arguments.
347-
348-
### `disable-next-line`
349-
350-
Use the `#disable-next-line` directive to suppress diagnostics for the statement immediately following the directive. You must specify at least one identifier after the directive. If you don't provide any identifiers, the compiler reports an error. The identifiers you specify after the directive can refer to:
344+
You must specify at least one identifier after the directive. If you don't provide any identifiers, the compiler reports an error. The identifiers you specify after the directive can refer to:
351345

352346
* [Bicep compiler diagnostics](./bicep-core-diagnostics.md), such as `BCP138`
353347
* [Bicep linter rules](./linter.md), such as `no-unused-params`
354348

355-
The following example suppresses a compiler diagnostic:
349+
You separate arguments by using spaces. The linter rules and diagnostic codes are case sensitive.
356350

357-
```bicep
358-
#disable-next-line BCP138
359-
resource stg 'Microsoft.Storage/storageAccounts@2025-06-01' = {
360-
name: 'examplestorage'
361-
}
362-
```
363-
364-
The following example suppresses a linter rule:
351+
Bicep currently supports three directive types:
365352

366-
```bicep
367-
#disable-next-line no-unused-params
368-
param unusedParam string
369-
```
353+
* `#disable-next-line` — disables one or more diagnostics for the next line only
354+
* `#disable-diagnostics` — disables one or more diagnostics for an entire file or until re-enabled
355+
* `#restore-diagnostics` — re-enables previously disabled diagnostics
370356

371357
The following example suppresses multiple diagnostics and rules:
372358

373359
```bicep
374-
#disable-next-line BCP138 no-unused-params
375-
param example string
360+
#disable-diagnostics no-unused-vars BCP335
361+
362+
var location = 'eastus'
363+
364+
param storageCount int
365+
366+
resource accounts 'Microsoft.Storage/storageAccounts@2025-06-01' = [for i in range(0, storageCount): if (i % 2 == 0) {
367+
name: 'sa0820${i}'
368+
location: resourceGroup().location
369+
sku: {
370+
name: 'Standard_LRS'
371+
}
372+
kind: 'StorageV2'
373+
}]
376374
```
377375

378376
Use directives sparingly and only when you review and intentionally suppress a diagnostic or linter rule. Excessive use can reduce template readability and maintainability. Add a comment explaining why the rules or the diagnostic codes don't apply to this line.
@@ -405,7 +403,7 @@ For more information, see [Iterative loops in Bicep](loops.md).
405403

406404
## Conditional deployment
407405

408-
You can add a resource or module to your Bicep file that's conditionally deployed. During deployment, the condition is evaluated and the result determines whether the resource or module is deployed. Use the `if` expression to define a conditional deployment.
406+
You can add a resource or module to your Bicep file for conditional deployment. During deployment, the condition is evaluated and the result determines whether the resource or module is deployed. Use the `if` expression to define a conditional deployment.
409407

410408
```bicep
411409
param deployZone bool
@@ -420,17 +418,17 @@ For more information, see [Conditional deployments in Bicep with the if expressi
420418

421419
## Whitespace
422420

423-
Spaces and tabs are ignored when you author Bicep files.
421+
Bicep files ignore spaces and tabs.
424422

425-
Bicep is newline sensitive. For example:
423+
Bicep is sensitive to newlines. For example:
426424

427425
```bicep
428426
resource sa 'Microsoft.Storage/storageAccounts@2025-06-01' = if (newOrExisting == 'new') {
429427
...
430428
}
431429
```
432430

433-
Can't be written as:
431+
You can't write it as:
434432

435433
```bicep
436434
resource sa 'Microsoft.Storage/storageAccounts@2025-06-01' =
@@ -439,7 +437,7 @@ resource sa 'Microsoft.Storage/storageAccounts@2025-06-01' =
439437
}
440438
```
441439

442-
Define [objects](./data-types.md#objects) and [arrays](./data-types.md#arrays) in multiple lines.
440+
You can define [objects](./data-types.md#objects) and [arrays](./data-types.md#arrays) across multiple lines.
443441

444442
## Comments
445443

@@ -480,6 +478,5 @@ For multiple-line declaration samples, see [arrays](./data-types.md#arrays) and
480478

481479
## Related content
482480

483-
* For an introduction to Bicep, see [What is Bicep?](./overview.md).
481+
* For an introduction to Bicep, see [What is Bicep?](./overview.md)
484482
* For Bicep data types, see [Data types](./data-types.md).
485-

articles/azure-resource-manager/bicep/linter.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Use Bicep linter
33
description: Learn how to use Bicep linter.
44
ms.topic: how-to
55
ms.custom: devx-track-bicep
6-
ms.date: 01/16/2026
6+
ms.date: 01/30/2026
77
---
88

99
# Use Bicep linter
@@ -94,16 +94,7 @@ You can integrate these checks as a part of your CI/CD pipelines. You can use a
9494

9595
Sometimes a rule has false positives. For example, you might need to include a link to a blob storage directly without using the [environment()](./bicep-functions-deployment.md#environment) function.
9696

97-
In this case, you can disable the warning for one line only, not the entire document, by adding the `#disable-next-line` directive before the line with the warning.
98-
99-
```bicep
100-
#disable-next-line no-hardcoded-env-urls //Direct download link to my toolset
101-
scriptDownloadUrl: 'https://mytools.blob.core.windows.net/...'
102-
```
103-
104-
For more information about using directives in Bicep, see [Directives](./file.md#directives).
105-
106-
If you want to suppress a linter rule, change the level of the rule to `Off` in [bicepconfig.json](./bicep-config-linter.md). In the following example, the `no-deployments-resources` rule is suppressed:
97+
You can suppress Bicep linter rules by using `disable-next-line` and `disable-diagnostics`. See [Directives](./file.md#directives). If you want to suppress a linter rule, change the level of the rule to `Off` in [bicepconfig.json](./bicep-config-linter.md). In the following example, the `no-deployments-resources` rule is suppressed:
10798

10899
```json
109100
{

0 commit comments

Comments
 (0)