get-azurekeyvaultkey does not return “public key”

梦想的初衷 提交于 2021-02-11 15:26:26

问题


I am just testing out Azure Key Vault with key/pairs and am attempting to retrieve the public key.

I first created a Key Vault (name = "VaultTest") using Azure portal.

I then created a Key (Name = "TestKey1") again using Azure portal.

I see the key in the portal and when I click on it I see the following information:

Properties:

Key Type: RSA

RSA Key Size 2048

Created: "date time"

Updated: "date time"

Key Identifier: //vault path/keys/TestKey1/Key identifier

Settings:

Set activation date: "unchecked"

Set expiration date: "unchecked"

Enabled: True

Tags "none"

Permitted operations:

Encrypt: true

Decrypt: true

Sign: true

Verify: true

Wrap key: true

Unwrap key: true

Notice that there is no public key information displayed so I switched over to Azure Cloud Shell and executed the following command:

Get-AzureKeyVaultKey -vaultname 'VaultTest' -name 'TestKey1'

It returns VaultName, Name, Version, Id, Enabled, Expires, Not Before, Created, Updated, Purge Disabled and Tags, but no Key.

All the examples I read online (albeit somewhat old) show fields Attributes and Key being returned but those are not returning for me.

I read somewhere that if you call the URI it will return the public key info, so I copy/pasted the URI into a browser but this returns to me:

{"error":{"code":"Unauthorized","message":"Request is missing a Bearer or PoP token."}}

Am I doing something brain dead or has the function get-azurekeyvaultkey changed? If it has changed how does one get the public key information for a specific key stored in Key Vault?


回答1:


I can reproduce your issue with Get-AzureKeyVaultKey -vaultname 'VaultTest' -name 'TestKey1'.

But actually it returns the Attributes and Key that you want, just pass the | ConvertTo-Json like below.

Get-AzureKeyVaultKey -vaultname 'VaultTest' -name 'TestKey1' | ConvertTo-Json



来源:https://stackoverflow.com/questions/60312227/get-azurekeyvaultkey-does-not-return-public-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!