有人可以帮我在ARM模板中找到系统分配的身份的客户端机密,还是建议其他方法?
我有一个ARM模板,它使用系统分配的标识创建一个Logic App,现在我想设置一个API连接以从事件网格触发(不使用门户网站UI或单独的powershell命令)。>
我不知道如何为系统分配的身份获取客户端密码。这将使我能够遵循以下先前问题的答案:
这是我到目前为止所拥有的:
"resources": [
{
"apiVersion": "2016-06-01",
"type": "Microsoft.logic/workflows",
"name": "[variables('logicName')]",
"location": "[resourceGroup().location]",
"identity": {
"type": "SystemAssigned"
},
"dependsOn": [
"[variables('connections_azuretables_name')]"
],
"properties": {
"state": "Enabled",
"definition": {
<<SNIP>>
}
}
},
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('azureEventGridConnectionAPIName')]",
"location": "[resourceGroup().location]",
"properties": {
"api": {
"id": "[concat('/subscriptions/subscriptionId', '/providers/Microsoft.Web/locations/', 'eastasia', '/managedApis/', 'azureeventgrid')]"
},
"parameterValues": {
"token:clientId": "[reference(variables('logicName'), '2016-06-01', 'Full').identity.principalId]",
"token:clientSecret": "########### STUCK HERE #################",
"token:TenantId": "[reference(variables('logicName'), '2016-06-01', 'Full').identity.tenantId]",
"token:grantType": "client_credentials"
},
"displayName": "[variables('azureEventGridConnectionAPIName')]"
},
"dependsOn": []
}
],
答案 0 :(得分:0)
受管身份没有客户机密。它只有证书,您无法访问。
该模板将必须在逻辑应用程序中执行才能获取访问令牌,我怀疑它可以这样做。
答案 1 :(得分:0)
对于任何想知道的人来说,手动创建服务主体然后将其输入到ARM模板中都是非常简单的:
> az ad sp create-for-rbac --name MyPrincipal
{
"appId": "##############",
"displayName": "MyPrincipal",
"name": "http://MyPrincipal",
"password": "##############",
"tenant": "##############"
}
现在将appId
(作为clientId
)password
(作为clientSecret
)和tenant
(作为tenantId
)传递到{{ parameterValues
中的1}}块。这将为您的逻辑应用程序建立一个事件网格API连接,但会影响访问策略和ARM模板之外的身份管理开销。
我使用的实际解决方案是在事件网格上创建Webhook事件订阅,然后将我的逻辑应用程序设置为具有Web Hook触发器。这样就可以了。
这是一个示例解决方案:
Microsoft.Web/connections