我有一个创建 SQL Server 和 VM 的 Azure ARM 模板。两者都参考 KeyVault 来获取管理员密码:
"resources": [
{
"type": "Microsoft.Sql/servers",
"kind": "v12.0",
"name": "[variables('vSqlServerName')]",
"tags": {
"Environment": "[parameters('pEnvironment')]",
"DisplayName": "SQL Server",
"UDID": "SQLServer" // Unique Deployment ID (for later reference)
},
"apiVersion": "[variables('vSqlAPIVersion')]",
"location": "[resourceGroup().location]",
"properties": {
"administratorLogin": "[variables('vSqlAdminUser')]",
"administratorLoginPassword":{
"reference": {
"keyVault": {
"id": "[concat(resourceGroup().id, '/providers/Microsoft.KeyVault/vaults/', variables('vKeyVaultName'))]"
},
"secretName": "SQLDW-AdminPassword"
}
},
"version": "12.0"
},
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(variables('vSqlVMName'), variables('vSuffixVM'))]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {
"hardwareProfile": {
"vmSize": "Standard_DS5_v2"
}
"osProfile": {
"computerName": "[variables('vSqlVMName')]",
"adminUsername": "[variables('vWinAdminUser')]",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
},
"secrets": [],
"adminPassword": {
"reference": {
"keyVault": {
"id": "[concat(resourceGroup().id, '/providers/Microsoft.KeyVault/vaults/', variables('vKeyVaultName'))]"
},
"secretName": "VM-LocalAdminPassword"
}
}
}
}
]
这适用于 SQL,但不适用于 VM,我得到的错误是:{ 11:16:27 - [ERROR] "target": "vm.properties.osProfile.adminPassword", 11:16:27 - [错误]“消息”:“解析值时遇到意外字符:{。11:16:27 - [错误]路径'properties.osProfile.adminPassword',第1行,位置785。” 11:16:27 - [错误]},