我正在尝试使用secretName
和secretValue
部署密钥库,并且在具有所有秘密的天蓝色devops中创建了一个变量组,并且我在参数文件中使用以下参数,但是当部署后,秘密值将存储为$(secret),而不是实际存储在Azure DevOps任务组中的密码。
"secretsObject": {
"value": {
"secrets": [
{
"secretName": "App012",
"secretValue": "$(mysecret)"
},
这是我在密钥库模板中得到的:
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(parameters('keyVaultName'), '/', parameters('secretsObject').secrets[copyIndex()].secretName)]",
"apiVersion": "2018-02-14",
"dependsOn": [
"[concat('Microsoft.KeyVault/vaults/', parameters('keyVaultName'))]"
],
"copy": {
"name": "secretsCopy",
"count": "[length(parameters('secretsObject').secrets)]"
},
"properties": {
"value": "[parameters('secretsObject').secrets[copyIndex()].secretValue]"
}
}
]
}
有什么想法如何将“ secretvalue”作为变量传递?
答案 0 :(得分:1)
我相信您在问如何利用存储为变量组的机密通过Azure DevOps与ARM模板一起安全地部署。如果是这种情况,请在发布任务中使用Override Template Parameters。
这将采用-NameOfARMParameter $(NameofDevOpsVariable)的格式
在您的情况下,它将是-mysecret $(NameOfDevOpsVariable)
部署.json对于参数声明应如下所示:
"secretValue": {
"type": "string",
"metadata": {
"description": "This is for receiving a value from DevOps releases of the secret to be stored in the key vault"
}
},
"secretName": {
"type": "string",
"metadata": {
"description": "Name of the Secret"
}
},
用于实际部署
{
"type": "Microsoft.KeyVault/vaults/secrets",
"name": "[concat(variables('keyVaultName'),'/',parameters('secretName'))]",
"apiVersion": "2018-02-14",
"properties": {
"contentType": "text/plain",
"value": "[parameters('secretValue')]"
},
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]"
]
},
如果这些值将由Dev Ops提供,则参数文件中不需要任何内容
答案 1 :(得分:0)
您需要使用密钥/秘钥链接创建一个参数文件。
这里是一个示例:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminLogin": {
"value": "exampleadmin"
},
"adminPassword": {
"reference": {
"keyVault": {
"id": "/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.KeyVault/vaults/<vault-name>"
},
"secretName": "ExamplePassword"
}
},
"sqlServerName": {
"value": "<your-server-name>"
}
}
}
更多信息:
https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/parameter-files