What this thread does
Do first: run az bicep version, then put @secure() on the reusable object type itself or on an inline object parameter.
Short answer
As of November 2026, Bicep 0.49.2 is the release reference; current user-defined type docs list secure for string/object types. The reported error is The decorator "secure" may not be used on statements whose declared type is a reference to a user-defined type. Jonny Eskew's June 27, 2023 explanation identifies the ARM representation restriction; the correct repair is to change declaration placement, not remove secrecy.
Choose / don't choose
- Reusable shape: choose a secure named type; don't decorate only one use of an otherwise unsecured named type.
- One-use shape: choose a secure inline parameter so shape and security are declared together; don't create a shared type merely to bypass this error (Eskew).
- Generic object: choose
@secure()on anobjectparameter when structural validation isn't needed; don't use a plain unsecured object for secret values (parameters).
Not for: choosing an external secrets store; see env-files-doppler-infisical-1password-or-sops-for-small-team-secrets.
Settings that matter
| Declaration or command | Value / condition | Applies to | Source |
|---|---|---|---|
@secure() on type | Apply to a string/object type definition | Current Bicep docs | secure types |
@secure() on inline param | Place before param properties { foo: string? }; optional default {} only when valid for that shape | Inline object parameter | maintainer example |
@secure() on param ... object | Protect the whole object; value excluded from deployment history/logging | Current Bicep parameters | parameters |
az bicep version / bicep --version | Inspect the Azure CLI-managed compiler and standalone compiler respectively; they are distinct installations | Current Bicep CLI docs | CLI |
az bicep build --file main.bicep | Build converts Bicep to an ARM JSON template; inspect it before deploying | Current Bicep CLI docs | CLI |
Reusable declaration, adapted from Eskew's example:
@secure()
type propertiesType = {
foo: string?
}
param properties propertiesType = {}
For a one-use declaration:
@secure()
param properties {
foo: string?
} = {}
The secure boundary is the entire object (maintainer explanation, secure type docs).
Order of operations
1. Identify the compiler the actual deployment command invokes; compare its version with the editor/standalone binary (CLI). 2. Move the decorator to the named object type, or replace the named reference with an inline object declaration. Retain the secure boundary (secure types, Eskew examples). 3. Compile with the deployment compiler and inspect that the emitted parameter remains secure. The issue discussion suspects how the Az PowerShell module serializes aggregate values as the cause of that reported error (CLI, issue discussion).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
The decorator "secure" may not be used | Statements whose declared type is a reference to a user-defined type | Secure the type definition or inline the parameter shape | Damaschke/Eskew, September 2024, current secure types |
must be declared with the '@secure()' attribute | A historical linter false positive can object to a parameter already using a secure type | Prefer the inline secure shape when affected; distinguish linter output from compiler rejection | Eskew, September 16, 2024 |
David Jürgens opened the original report on June 26, 2023. For the later PowerShell aggregate-value discussion, a move to a separate issue was proposed.
Missing
- Earliest shipped compiler version for secure named types: the maintainer announcement names a planned release, but no historical release page was available to establish its exact shipped boundary. Current support is documented; no complete affected-version range is claimed.
- The source template and deployment client are unspecified; inspect those before attributing an error to compilation or serialization.
Checked
2026-11-12; Bicep 0.49.2 release, current type/parameter/CLI documentation and dated Jürgens/Eskew/Damaschke discussion read. No compilation or deployments executed.
Started from a post by @Microsoft, packaged by the editor. Original post