我正在嘗試創建一個主密鑰保管庫,它將包含所有要作爲特定用戶進行身份驗證的證書。ARM模板中的KeyVault參考問題
我有2個服務主體=>一個用於我的應用程序,一個用於部署。 這個想法是,部署服務主體可以訪問密鑰保管庫,並將位於那裏的證書添加到Web應用程序的Store中。
我已經創建了服務主體,並且已授予他關鍵密鑰庫的所有權限。此外,我還在ARM模板中爲該密鑰保管庫啓用了訪問機密。
使用powershell我能夠以部署SP身份登錄並檢索祕密(證書)。
但是,在部署引用密鑰庫的ARM模板時,這不起作用。我得到了以下錯誤:
New-AzureRmResourceGroupDeployment : 11:16:44 - Resource Microsoft.Web/certificates 'test-certificate' failed with message '{ "Code": "BadRequest", "Message": "The service does not have access to '/subscriptions/98f06e7e-1016-4088-843f-62690f3bb306/resourcegroups/rg-temp/providers/microsoft.keyvault/vaults/master-key-vault' Key Vault. Please make sure that you have granted necessary permissions to the service to perform the request operation.", "Target": null, "Details": [ { "Message": "The service does not have access to '/subscriptions/xxxx/resourcegroups/xxx/providers/microsoft.keyvault/vaults/master-key-vault' Key Vault. Please make sure that you have granted necessary permissions to the service to perform the request operation." },
我的胳膊模板看起來是這樣的:
{
"type":"Microsoft.Web/certificates",
"name":"test-certificate",
"apiVersion":"2016-03-01",
"location":"[resourceGroup().location]",
"properties":{
"keyVaultId":"[resourceId('rg-temp', 'Microsoft.KeyVault/vaults', 'master-key-vault')]",
"keyVaultSecretName":"kv-certificate-test",
"serverFarmId":"[resourceId('Microsoft.Web/serverfarms', 'asp-test')]"
}
},
這是一個錯誤?因爲我能夠檢索使用部署SP與證書:
$key = Get-AzureKeyVaultSecret -VaultName "master-key-vault" -Name "testenvironmentcertificate"
這是我的ARM模板:(注意,密鑰庫的生活比在ARM模板的資源另一個資源組)
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type":"Microsoft.Web/certificates",
"name":"test-certificate",
"apiVersion":"2016-03-01",
"location":"[resourceGroup().location]",
"properties":{
"keyVaultId":"/subscriptions/xxx/resourceGroups/rg-temp/providers/Microsoft.KeyVault/vaults/xxx",
"keyVaultSecretName":"testcert",
"serverFarmId":"[resourceId('Microsoft.Web/serverfarms', 'asp-test')]"
}
},
{
"name": "wa-test1",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2016-08-01",
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', 'asp-test')]"
],
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/asp-test')]": "Resource",
"displayName": "wa-test1"
},
"properties": {
"name": "wa-test1",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', 'asp-test')]"
}
},
{
"name": "asp-test",
"type": "Microsoft.Web/serverfarms",
"location": "[resourceGroup().location]",
"apiVersion": "2014-06-01",
"dependsOn": [],
"tags": {
"displayName": "appServicePlan"
},
"properties": {
"name": "asp-test",
"sku": "Free",
"workerSize": "Small",
"numberOfWorkers": 1
}
}
],
"outputs": {}
}
可以分享你的模板?你可以刪除敏感信息 – 4c74356b41
我已編輯我的問題:) – Identity
好吧,乍一看這看起來很好,我不知道什麼可能是錯的,你可以創建另一個關鍵的保險櫃,只需使用您的訂閱管理部署模板(並驗證管理員擁有keyvault的所有權利,keyvault允許模板部署?)? – 4c74356b41