Azure KeyVault 遍历保管库中的所有机密
Azure KeyVault iterate over all secrets in a vault
为了简单起见,假设我想使用 Azure REST API.
从特定保管库中的所有机密构建字典,其中包含机密名称和机密值
我面临的问题是 Get Secrets API 调用 returns SecretListResult,其中包含 SecretItem 列表。 SecretItem 有 ID 元素,但没有名称,也没有值。 GetSecret API 需要秘密名称而不是秘密 ID,到目前为止我找不到将 ID 转换为名称的方法。
如有任何建议,我们将不胜感激
谢谢。
// 获取秘密列表
GET https://alice.vault.azure.net/secrets?api-version=2015-06-01
Response Body:
{
"value": [
{
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret1",
"attributes": {
"enabled": true,
"created": 1496749576,
"updated": 1496749576
}
},
{
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret2",
"attributes": {
"enabled": true,
"created": 1496749590,
"updated": 1496749590
}
}
],
"nextLink": null
}
// 获取秘密属性和值
解析id
,查找最后一次出现的/
以获得秘密名称。每项调用一次。
GET https://alice.vault.azure.net/secrets/secret1/?api-version=2015-06-01
Response Body:
{
"value": "5up3r1ee7s3cr3t",
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret1/6ac15a48877148e094276504d73e95a1",
"attributes": {
"enabled": true,
"created": 1496749576,
"updated": 1496749576
}
}
GET https://alice.vault.azure.net/secrets/secret2/?api-version=2015-06-01
Response Body:
{
"value": "@n0th3r5up3r1ee7s3cr3t",
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret2/2b34de363d6445ba83bb23bafaea6658",
"attributes": {
"enabled": true,
"created": 1496749590,
"updated": 1496749590
}
}
资料来源:我刚刚通过 -Debug
查看了 Azure PowerShell 在线调用的内容,例如:
Get-AzureKeyVaultSecret -VaultName Alice -Debug
Get-AzureKeyVaultSecret -VaultName Alice -Name secret1 -Debug
为了简单起见,假设我想使用 Azure REST API.
从特定保管库中的所有机密构建字典,其中包含机密名称和机密值我面临的问题是 Get Secrets API 调用 returns SecretListResult,其中包含 SecretItem 列表。 SecretItem 有 ID 元素,但没有名称,也没有值。 GetSecret API 需要秘密名称而不是秘密 ID,到目前为止我找不到将 ID 转换为名称的方法。
如有任何建议,我们将不胜感激
谢谢。
// 获取秘密列表
GET https://alice.vault.azure.net/secrets?api-version=2015-06-01
Response Body:
{
"value": [
{
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret1",
"attributes": {
"enabled": true,
"created": 1496749576,
"updated": 1496749576
}
},
{
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret2",
"attributes": {
"enabled": true,
"created": 1496749590,
"updated": 1496749590
}
}
],
"nextLink": null
}
// 获取秘密属性和值
解析id
,查找最后一次出现的/
以获得秘密名称。每项调用一次。
GET https://alice.vault.azure.net/secrets/secret1/?api-version=2015-06-01
Response Body:
{
"value": "5up3r1ee7s3cr3t",
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret1/6ac15a48877148e094276504d73e95a1",
"attributes": {
"enabled": true,
"created": 1496749576,
"updated": 1496749576
}
}
GET https://alice.vault.azure.net/secrets/secret2/?api-version=2015-06-01
Response Body:
{
"value": "@n0th3r5up3r1ee7s3cr3t",
"contentType": "text",
"id": "https://alice.vault.azure.net/secrets/secret2/2b34de363d6445ba83bb23bafaea6658",
"attributes": {
"enabled": true,
"created": 1496749590,
"updated": 1496749590
}
}
资料来源:我刚刚通过 -Debug
查看了 Azure PowerShell 在线调用的内容,例如:
Get-AzureKeyVaultSecret -VaultName Alice -Debug
Get-AzureKeyVaultSecret -VaultName Alice -Name secret1 -Debug