Skip to content

Commit 35adeaa

Browse files
Merge pull request #299588 from mumian/0507-secure-output
Document the secure outputs decorator
2 parents c80a2f6 + e3cb3bf commit 35adeaa

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

articles/azure-resource-manager/bicep/data-types.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Data types in Bicep
33
description: This article describes the data types that are available in Bicep.
44
ms.topic: reference
5-
ms.date: 01/10/2025
5+
ms.date: 05/09/2025
66
ms.custom: devx-track-bicep
77
---
88

@@ -423,7 +423,7 @@ You can use the union type syntax in [user-defined data types](./user-defined-da
423423
424424
Secure strings use the same format as string, and secure objects use the same format as object. With Bicep, you add the `@secure()` [decorator](./parameters.md#use-decorators) to a string or object.
425425
426-
When you set a parameter to a secure string or secure object, the value of the parameter isn't saved to the deployment history or logged. If you set that secure value to a property that isn't expecting a secure value, the value isn't protected. For example, if you set a secure string to a tag, that value is stored as plain text. Use secure strings for passwords and secrets.
426+
When you set a parameter (or an output) to a secure string or secure object, the value of the parameter (or the output) isn't saved to the deployment history or logged. If you set that secure value to a property that isn't expecting a secure value, the value isn't protected. For example, if you set a secure string to a tag, that value is stored as plain text. Use secure strings for passwords and secrets.
427427
428428
The following example shows two secure parameters:
429429
@@ -435,6 +435,8 @@ param password string
435435
param configValues object
436436
```
437437

438+
For more information, see [Secure parameters](./parameters.md#secure-parameters) and [Secure outputs](./outputs.md#secure-outputs).
439+
438440
## Data type assignability
439441

440442
In Bicep, you can assign a value of one type (source type) to another type (target type). The following table shows which source type (listed horizontally) you can or can't assign to which target type (listed vertically). In the table, _X_ means assignable, an empty space means not assignable, and _?_ means only if the types are compatible.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep modules
33
description: This article describes how to define a module in a Bicep file and how to use module scopes.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 03/25/2025
6+
ms.date: 05/09/2025
77
---
88

99
# Bicep modules
@@ -545,6 +545,8 @@ module stgModule '../create-storage-account/main.bicep' = {
545545
output storageEndpoint object = stgModule.outputs.storageEndpoint
546546
```
547547

548+
With Bicep version 0.35.1 and later, the `@secure()` decorator can be applied to module outputs to mark them as sensitive, ensuring that their values are not exposed in logs or deployment history. This is useful when a module needs to return sensitive data, such as a generated key or connection string, to the parent Bicep file without risking exposure. For more information, see [Secure outputs](./outputs.md#secure-outputs).
549+
548550
## Related content
549551

550552
- For a tutorial, see [Build your first Bicep template](/training/modules/deploy-azure-resources-by-using-bicep-templates/).

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Outputs in Bicep
33
description: Learn how to define output values in Bicep.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 03/25/2025
6+
ms.date: 05/09/2025
77
---
88

99
# Outputs in Bicep
@@ -68,6 +68,7 @@ Decorators are written in the format `@expression` and are placed above output d
6868
| [minLength](#length-constraints) | array, string | int | This provides the minimum length for string and array outputs, and the value is inclusive. |
6969
| [minValue](#integer-constraints) | int | int | This provides the minimum value for the integer output, and the value is inclusive. |
7070
| [sealed](#sealed) | object | none | Elevate [BCP089](./diagnostics/bcp089.md) from a warning to an error when a property name of a use-define data type is likely a typo. For more information, see [Elevate error level](./user-defined-data-types.md#elevate-error-level). |
71+
| [secure](#secure-outputs) | string, object | none | Marks the output as secure. The value for a secure output isn't saved to the deployment history and isn't logged. For more information, see [Secure strings and objects](data-types.md#secure-strings-and-objects). |
7172

7273
Decorators are in the [`sys` namespace](bicep-functions.md#namespaces-for-functions). If you need to differentiate a decorator from another item with the same name, preface the decorator with `sys`. For example, if your Bicep file includes a parameter named `description`, you must add the `sys` namespace when using the **description** decorator.
7374

@@ -150,6 +151,20 @@ When you provide a `@metadata()` decorator with a property that conflicts with a
150151

151152
See [Elevate error level](./user-defined-data-types.md#elevate-error-level).
152153

154+
### Secure outputs
155+
156+
With Bicep version 0.35.1 and later, you can mark string or object outputs as secure. When an output is decorated with `@secure()`, Azure Resource Manager treats the output value as sensitive, preventing it from being logged or displayed in deployment history, Azure portal, or command-line outputs.
157+
158+
```bicep
159+
@secure()
160+
output demoPassword string
161+
162+
@secure()
163+
output demoSecretObject object
164+
```
165+
166+
The `@secure()` decorator is valid only for outputs of type string or object, as these align with the [secureString](../templates/syntax.md#outputs) and [secureObject](../templates/syntax.md#outputs) types in ARM templates. To pass arrays or numbers securely, wrap them in a secureObject or serialize them as a secureString.
167+
153168
## Conditional output
154169

155170
When the value to return depends on a condition in the deployment, use the `?` operator.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Parameters in Bicep files
33
description: Learn how to define and use parameters in a Bicep file.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 03/25/2025
6+
ms.date: 05/09/2025
77
---
88

99
# Parameters in Bicep
@@ -207,7 +207,7 @@ See [Elevate error level](./user-defined-data-types.md#elevate-error-level).
207207

208208
### Secure parameters
209209

210-
You can mark string or object parameters as secure. The value of a secure parameter isn't saved to the deployment history and isn't logged.
210+
You can mark string or object parameters as secure. When a parameter is decorated with `@secure()`, Azure Resource Manager treats the parameter value as sensitive, preventing it from being logged or displayed in deployment history, Azure Portal, or command-line outputs.
211211

212212
```bicep
213213
@secure()
@@ -232,6 +232,8 @@ resource keyvault 'Microsoft.KeyVault/vaults@2019-09-01' = {
232232
}
233233
```
234234

235+
The `@secure()` decorator is valid only for parameters of type string or object, as these align with the [secureString](../templates/syntax.md#parameters) and [secureObject](../templates/syntax.md#parameters) types in ARM templates. To pass arrays or numbers securely, wrap them in a secureObject or serialize them as a secureString.
236+
235237
## Use objects as parameters
236238

237239
It can be easier to organize related values by passing them in as an object. This approach also reduces the number of parameters in the template.

0 commit comments

Comments
 (0)