Skip to content

Keyvault oct hsm#29579

Open
MaddyMicrosoft wants to merge 25 commits into
Azure:mainfrom
MaddyMicrosoft:keyvault-oct-hsm
Open

Keyvault oct hsm#29579
MaddyMicrosoft wants to merge 25 commits into
Azure:mainfrom
MaddyMicrosoft:keyvault-oct-hsm

Conversation

@MaddyMicrosoft
Copy link
Copy Markdown
Member

@MaddyMicrosoft MaddyMicrosoft commented May 13, 2026

Description

Enable Azure Key Vault (AKV Premium) support for AES (oct-HSM) keys in Azure PowerShell. Managed HSM (MHSM) already supported AES; AKV was explicitly blocked in Track2VaultClient.CreateKey. This PR removes that blocker, plumbs the oct-HSM kty rewrite at the cmdlet layer, exercises AES values in the algorithm completer, and refactors the option-building inside Track2HsmClient behind a unit-test safety net.

What changed

  • Track2VaultClient.CreateKey — accepts oct / oct-HSM and routes to KeyClient.CreateOctKey. Removes the NotSupportedException and the hardcoded "oct (AES) is only supported by managed HSM" assumption.
  • AddAzureKeyVaultKey — when called with -KeyType oct -Destination HSM against a vault, rewrites kty oct → oct-HSM (matches the existing RSA → RSA-HSM / EC → EC-HSM rewrite). No new parameters; behavior on MHSM is unchanged.
  • InvokeAzureKeyVaultKeyOperation — extends the -Algorithm argument completer with AES values (A128CBC, A192CBC, A256CBC, *CBCPAD, *GCM).
  • Track2HsmClient.CreateKey — small refactor of the per-key-type dispatch, behavior preserved.

Tests

  • AddKeyVaultOctKeyTests.cs — 8 cmdlet plumbing tests covering oct/RSA on vault and HSM, with/without -Destination HSM. Pins the kty rewrite contract.
  • All pass under dotnet test for the KeyVault test project.
  • Existing tests remain green.

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately — ✅ src/KeyVault/KeyVault/ChangeLog.md updated under ## Upcoming Release (past tense).
  • SHOULD regenerate markdown help files if there is cmdlet API change — ✅ src/KeyVault/KeyVault/help/Add-AzKeyVaultKey.md updated to document -KeyType oct -Destination HSM on AKV. No new parameters or output types.
  • SHOULD have proper test coverage for changes in pull request — ✅ 8 unit tests added (AddKeyVaultOctKeyTests, Track2HsmClientOptionsTests).
  • SHOULD NOT adjust version of module manually in pull request — ✅ Az.KeyVault.psd1 version not touched.

@MaddyMicrosoft MaddyMicrosoft added this to the Az 16.0.0 (06/02/2026) milestone May 13, 2026
Copilot AI review requested due to automatic review settings May 13, 2026 04:16
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables creation of AES (oct-HSM) keys in Azure Key Vault Premium (in addition to Managed HSM) by removing the explicit blocker in Track2 vault key creation, adding cmdlet-layer kty rewriting (octoct-HSM when -Destination HSM is used), and updating help/changelog and unit tests to cover the new behavior.

Changes:

  • Allow oct / oct-HSM key creation through Track2 vault client and route to KeyClient.CreateOctKey.
  • Rewrite -KeyType oct -Destination HSM to oct-HSM in Add-AzKeyVaultKey, and extend the key operation -Algorithm argument completer with AES algorithm identifiers.
  • Add/extend documentation (help + changelog) and add unit tests for the cmdlet plumbing behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/KeyVault/KeyVault/Track2Models/Track2VaultClient.cs Enables Track2 vault-side creation for oct/oct-HSM via CreateOctKey.
src/KeyVault/KeyVault/Track2Models/Track2HsmClient.cs Refactors/aligns Managed HSM key creation to use CreateOctKey for oct types.
src/KeyVault/KeyVault/Commands/Key/AddAzureKeyVaultKey.cs Rewrites octoct-HSM when creating vault keys with -Destination HSM.
src/KeyVault/KeyVault/Commands/Key/InvokeAzureKeyVaultKeyOperation.cs Expands the -Algorithm argument completer to include AES algorithms.
src/KeyVault/KeyVault/help/Add-AzKeyVaultKey.md Adds a new example documenting AES (oct-HSM) key creation in Premium Key Vault.
src/KeyVault/KeyVault/ChangeLog.md Adds an Upcoming Release note for Premium Key Vault AES (oct-HSM) creation support.
src/KeyVault/KeyVault.Test/UnitTests/AddKeyVaultOctKeyTests.cs Adds unit tests pinning the cmdlet contract around oct/oct-HSM creation routing and rewrite behavior.

Comment thread src/KeyVault/KeyVault/Track2Models/Track2VaultClient.cs Outdated
Comment thread src/KeyVault/KeyVault/Commands/Key/InvokeAzureKeyVaultKeyOperation.cs Outdated
Comment thread src/KeyVault/KeyVault/ChangeLog.md Outdated
Copilot AI review requested due to automatic review settings May 13, 2026 23:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Comment thread src/KeyVault/KeyVault.Test/UnitTests/AddKeyVaultOctKeyTests.cs
Comment thread src/KeyVault/KeyVault/Track2Models/Track2KeyOptionsFactory.cs Outdated
Comment thread src/KeyVault/KeyVault.Test/UnitTests/AddKeyVaultOctKeyTests.cs
Comment thread src/KeyVault/KeyVault/ChangeLog.md
Comment thread src/KeyVault/KeyVault/Commands/Key/InvokeAzureKeyVaultKeyOperation.cs Outdated
Copy link
Copy Markdown
Member

@notyashhh notyashhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall Looks Good!

Comment thread src/KeyVault/KeyVault/ChangeLog.md
@notyashhh
Copy link
Copy Markdown
Member

@MaddyMicrosoft Are we doing a general release or public preview? If public preview, we should not target main. We need to create a parallel branch to main to keep track of preview code.

Copilot AI review requested due to automatic review settings May 15, 2026 01:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread src/KeyVault/KeyVault/Commands/Key/AddAzureKeyVaultKey.cs Outdated
Comment thread src/KeyVault/KeyVault/Track2Models/Track2KeyOptionsFactory.cs Outdated
Comment thread src/KeyVault/KeyVault.Test/UnitTests/AddKeyVaultOctKeyTests.cs Outdated
Comment thread src/KeyVault/KeyVault/help/Add-AzKeyVaultKey.md
Copilot AI review requested due to automatic review settings May 15, 2026 05:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Vault/HSM Name : MyPremiumVault
Name : aesKey
Key Type : oct-HSM
Key Size : 256
```

Creates an AES (symmetric) HSM-protected key named `aesKey` in the Premium-SKU Azure Key Vault `MyPremiumVault`.
The `-Destination HSM` switch is required because symmetric (oct) keys in Azure Key Vault are always HSM-backed,
@MaddyMicrosoft MaddyMicrosoft changed the base branch from main to Maddy/Az.KeyVault-preview May 18, 2026 00:55
@github-actions
Copy link
Copy Markdown

‼️ DO NOT MERGE THIS PR ‼️
This PR was labeled "Do Not Merge" because it contains code change that cannot be merged. Please contact the reviewer for more information.

@notyashhh notyashhh changed the base branch from Az.KeyVault-preview to main May 20, 2026 16:36
Copilot AI review requested due to automatic review settings May 21, 2026 05:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/KeyVault/KeyVault.Test/ScenarioTests/OctHsmKeyTests.cs:51

  • This scenario test class has mismatched/extra closing braces at the end of the file, which will prevent the test project from compiling. Please remove the stray braces so the class and namespace close cleanly (compare with other ScenarioTests/*.cs files).
        {
            TestRunner.RunTestScript("Test-CreateOctHsmKeyAllSizes");
        }

            }
        }

Comment thread src/KeyVault/KeyVault/ChangeLog.md Outdated
## Upcoming Release
* Added support for creating AES (Advanced Encryption Standard, `oct`) HSM (hardware security module) keys in Azure Key Vault Premium via `Add-AzKeyVaultKey -KeyType oct -Destination HSM` (resulting `KeyType` is `oct-HSM`).
* Fixed `New-AzKeyVault` `RequestDisallowedByPolicy` error by explicitly setting `enableSoftDelete` in the request body to satisfy Azure Policy checks
* Fixed `New-AzKeyVault` `RequestDisallowedByPolicy` error by setting `enableSoftDelete` in request body
Copy link
Copy Markdown
Member

@notyashhh notyashhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!

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.

4 participants