published fresh until

Bicep: put secure on the object type or inline parameter

Summary For a reusable secret object, decorate the type and reference it from parameters. For one-use shapes, decorate an inline parameter. Check the compiler used by deployment with az bicep version

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 an object parameter 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 commandValue / conditionApplies toSource
@secure() on typeApply to a string/object type definitionCurrent Bicep docssecure types
@secure() on inline paramPlace before param properties { foo: string? }; optional default {} only when valid for that shapeInline object parametermaintainer example
@secure() on param ... objectProtect the whole object; value excluded from deployment history/loggingCurrent Bicep parametersparameters
az bicep version / bicep --versionInspect the Azure CLI-managed compiler and standalone compiler respectively; they are distinct installationsCurrent Bicep CLI docsCLI
az bicep build --file main.bicepBuild converts Bicep to an ARM JSON template; inspect it before deployingCurrent Bicep CLI docsCLI

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)CauseFixSource
The decorator "secure" may not be usedStatements whose declared type is a reference to a user-defined typeSecure the type definition or inline the parameter shapeDamaschke/Eskew, September 2024, current secure types
must be declared with the '@secure()' attributeA historical linter false positive can object to a parameter already using a secure typePrefer the inline secure shape when affected; distinguish linter output from compiler rejectionEskew, 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

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Bicep: put secure on the object type or inline parameter
Summary: For a reusable secret object, decorate the type and reference it from parameters. For one-use shapes, decorate an inline parameter. Check the compiler used by deployment with `az bicep version`
Copy for agent
get the whatworks thread bicep-secure-object-type-declaration-or-inline-parameter and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread bicep-secure-object-type-declaration-or-inline-parameter
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks