Skip to content

fix: make Bicep CMK specification examples cloud-aware - #3159

Merged
Alexander Sehr (AlexanderSehr) merged 2 commits into
Azure:mainfrom
arjenhuitema:fix/cmk-hsm-cloud-aware-examples
Nov 22, 2026
Merged

Alexander Sehr (AlexanderSehr) merged 2 commits into
Azure:mainfrom
arjenhuitema:fix/cmk-hsm-cloud-aware-examples

Conversation

@arjenhuitema

Copy link
Copy Markdown
Contributor

Overview/Summary

Make both Bicep customer-managed-key specification examples recognize Managed HSM resource IDs regardless of capitalization and derive HSM endpoints from the deployment's Azure environment rather than hardcoding public Azure.

Requested by Alexander Sehr (@AlexanderSehr) in this review comment on Azure/bicep-registry-modules#7528.

cc: Erika Gressi (@eriqua)

This PR fixes/adds/changes/removes

  1. Uses null-safe, case-insensitive Managed HSM resource-type detection in both CMK schemas.
  2. Derives the Managed HSM DNS suffix from environment().suffixes.keyvaultDns and reuses the resulting vault URI for versioned and versionless key identifiers.
  3. Preserves existing Key Vault handling, explicit key-version requirements, and auto-rotation behavior.

Breaking Changes

  1. None. The input interfaces and public-Azure URI formats are unchanged.
  2. No changes to supported key-version or auto-rotation combinations.

Local validation: Bicep 0.49.2.45890.

  • bicep build schema1.materialized.bicep --outfile schema1.materialized.json - passed.
  • bicep build schema2.materialized.bicep --outfile schema2.materialized.json - passed.
  • bicep build-params schema1-public-managedhsms.bicepparam --outfile schema1-public-managedhsms.json - passed.
  • bicep build-params schema2-hsm-without-version.bicepparam --outfile schema2-hsm-without-version.json - passed.
  • The complete offline expression matrix passed all 31 cases, including expected rejection of two invalid HSM version/rotation combinations. Cases covered public/Government/China DNS suffixes, resource-type capitalization, omitted/empty CMK configuration, Key Vault behavior, explicit versions, and auto-rotation.
  • git diff --check - passed.

The specification includes contain placeholders, so compilation used temporary materialized copies: a concrete common-types import, a declared managedIdentities input, and an output in place of the example resource. Offline cases evaluated expressions extracted from the edited files, with environment and existing-key metadata supplied as test inputs. These temporary validation files are not included in this PR. No Azure deployments were run.

The full Hugo site build was not run locally because Hugo is unavailable. GitHub PR checks remain pending.

As part of this Pull Request I have

  • Read the Contribution Guide and ensured this PR is compliant with the guide
  • Checked for duplicate Pull Requests
  • Associated it with relevant GitHub Issues or ADO Work Items (Internal Only)
  • Ensured my code/branch is up-to-date with the latest changes in the main branch
  • Ensured PR tests are passing
  • Updated relevant and associated documentation (e.g. Contribution Guide, Docs etc.)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AlexanderSehr
Alexander Sehr (AlexanderSehr) merged commit 341b145 into Azure:main Nov 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants