Arm 模板 - 在请求中发现错误的 JSON 内容
Arm Template - Bad JSON content found in the request
我正在尝试使用 Arm 模板向 KeyVault 添加访问策略,但我收到错误消息“在请求中找到错误的 JSON 内容”
细节:
内部错误:
代码:BadRequest
信息:
错误:
代码:BadRequest
消息:在请求中发现错误 JSON 内容..
我不明白我使用的模板有什么问题。
这是我正在使用的模板:
{
"contentVersion": "1.0.0.0",
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"parameters": {
"keyVault": {
"type": "string"
},
"resourceGroup": {
"type": "string"
},
"subscriptionId": {
"type": "string"
},
"tenantId": {
"type": "string"
},
"objectId": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(take(deployment().name, 50))]",
"apiVersion": "2017-05-10",
"resourceGroup": "[parameters('resourceGroup')]",
"subscriptionId": "[parameters('subscriptionId')]",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"name": "[concat(parameters('keyVault'), '/add')]",
"apiVersion": "2018-02-14",
"properties": {
"accessPolicies": [
{
"tenantId": "[parameters('tenantId')]",
"objectId": "[parameters('objectId')]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
]
}
}
]
}
}
}
]
}
如果您只想向现有的 Azure Key Vault 添加一些访问策略,我修改了您的模板如下:
{
"contentVersion": "1.0.0.0",
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"parameters": {
"keyVault": {
"type": "string"
},
"tenantId": {
"type": "string"
},
"objectId": {
"type": "string"
}
},
"resources": [{
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"name": "[concat(parameters('keyVault'), '/add')]",
"apiVersion": "2018-02-14",
"properties": {
"accessPolicies": [{
"tenantId": "[parameters('tenantId')]",
"objectId": "[parameters('objectId')]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
]
}
}
]
}
我已经通过 PowerShell 在我这边进行了测试,它正常工作。
结果:
我正在尝试使用 Arm 模板向 KeyVault 添加访问策略,但我收到错误消息“在请求中找到错误的 JSON 内容” 细节: 内部错误: 代码:BadRequest 信息: 错误: 代码:BadRequest 消息:在请求中发现错误 JSON 内容..
我不明白我使用的模板有什么问题。
这是我正在使用的模板:
{
"contentVersion": "1.0.0.0",
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"parameters": {
"keyVault": {
"type": "string"
},
"resourceGroup": {
"type": "string"
},
"subscriptionId": {
"type": "string"
},
"tenantId": {
"type": "string"
},
"objectId": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(take(deployment().name, 50))]",
"apiVersion": "2017-05-10",
"resourceGroup": "[parameters('resourceGroup')]",
"subscriptionId": "[parameters('subscriptionId')]",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"name": "[concat(parameters('keyVault'), '/add')]",
"apiVersion": "2018-02-14",
"properties": {
"accessPolicies": [
{
"tenantId": "[parameters('tenantId')]",
"objectId": "[parameters('objectId')]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
]
}
}
]
}
}
}
]
}
如果您只想向现有的 Azure Key Vault 添加一些访问策略,我修改了您的模板如下:
{
"contentVersion": "1.0.0.0",
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"parameters": {
"keyVault": {
"type": "string"
},
"tenantId": {
"type": "string"
},
"objectId": {
"type": "string"
}
},
"resources": [{
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"name": "[concat(parameters('keyVault'), '/add')]",
"apiVersion": "2018-02-14",
"properties": {
"accessPolicies": [{
"tenantId": "[parameters('tenantId')]",
"objectId": "[parameters('objectId')]",
"permissions": {
"keys": [
"get",
"list"
],
"secrets": [
"get",
"list"
],
"certificates": [
"get",
"list"
]
}
}
]
}
}
]
}
我已经通过 PowerShell 在我这边进行了测试,它正常工作。 结果: