我正在创建Azure Key Vault。我正在使用下面的ARM JSON模板。我在Azure AD中创建了一个应用程序,我正在尝试授予该应用程序所有权限,以便我可以使用此应用程序凭据从密钥库客户端连接到密钥库。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vaults_qnvaultdev_name": {
"type": "string"
},
"vaults_location": {
"type": "string"
},
"vaults_skufamily": {
"type": "string"
},
"vaults_skuname": {
"type": "string"
},
"vaults_tenantid": {
"type": "string"
},
"vaults_objectid": {
"type": "string"
}
},
"variables": {},
"resources": [
{
"comments": "Generalized from resource: '/subscriptions/subscription().subscriptionId/resourceGroups/resourceGroup().name/providers/Microsoft.KeyVault/vaults/[parameters('vaults_qnvaultdev_name')]'.",
"type": "Microsoft.KeyVault/vaults",
"name": "[parameters('vaults_qnvaultdev_name')]",
"apiVersion": "2015-06-01",
"location": "[parameters('vaults_location')]",
"tags": {},
"scale": null,
"properties": {
"sku": {
"family": "[parameters('vaults_skufamily')]",
"name": "[parameters('vaults_skuname')]"
},
"tenantId": "[parameters('vaults_tenantid')]",
"accessPolicies": [
{
"tenantId": "[parameters('vaults_tenantid')]",
"objectId": "[parameters('vaults_objectid')]",
"permissions": {
"keys": [
"All",
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"Backup",
"Restore"
],
"secrets": [
"All",
"Get",
"List",
"Set",
"Delete",
"Recover",
"Backup",
"Restore"
]
}
}
],
"enabledForDeployment": true
},
"dependsOn": []
}
]
}
模板执行良好,并且正在创建密钥库。我还可以在vault的访问策略中看到,主体被添加了所有权限。但是,在创建vault后,当我使用主体的客户端id和机密从客户端应用程序进行连接时,会出现“拒绝访问”错误。
我注意到,如果我通过门户并通过密钥库的访问策略手动添加应用程序,则Vault客户端能够成功进行身份验证。我错过什么了吗?
我手动将应用程序权限授予vault的访问策略,并检查了资源门户。然后,我看到在资源门户中生成的该应用程序的“对象Id”与我在Azure AD中看到的不同-在该应用程序的门户中。有什么不同的想法吗?