带有托管身份的事件网格API连接的ARM模板 [英] ARM template for Event Grid API Connection with managed identity
问题描述
从Logic App创建新的事件网格连接时,可以从以下3种连接身份验证方法中进行选择:
- 登录
- 服务主体
- 托管标识
#1登录要求用户以交互方式登录/身份验证。
#2服务主体要求提供租户、客户端ID和客户端机密值。
显然需要修改此类API连接的ARM模板:需要按如下方式添加parameterValues
。
"parameterValues": {
"token:clientId": "[parameters('ConnectionClientId')]",
"token:clientSecret": "[parameters('ConnectionClientSecret')]",
"token:TenantId": "[parameters('ConnectionTenantId')]",
"token:resourceUri": "https://management.core.windows.net/",
"token:grantType": "client_credentials"
}
#3托管标识只需要选择托管标识。虽然很清楚如何以交互方式创建此类API连接,但我找不到有关此类身份验证方法的ARM模板格式的任何信息。
所以问题是-事件网格连接的ARM模板与(UPDATE:用户分配)管理的身份到底应该是什么样子?以使创建的API连接如下所示:
更新:我需要在我的Logic App中使用用户分配的托管标识。下面提供的答案适用于系统分配的托管标识,但不适用于用户分配的标识。如果有人可以建议使用用户分配的托管标识的API连接的ARM模板,将不胜感激。
推荐答案
由于您可以拥有多个用户管理的标识,因此仅选择托管服务标识是不够的。相反,您必须包括要使用的标识的ID。
扩展@Jim-Xu的答案:
连接示例:
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[variables('eventApiConnectionName')]",
"location": "[resourceGroup().location]",
"kind": "V1",
"tags": "[parameters('resourceTags')]",
"properties": {
"displayName": "[variables('eventApiConnectionName')]",
"customParameterValues": {},
"api": {
"id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', resourceGroup().location, 'azureeventgrid')]"
},
"parameterValueType": "Alternative"
}
}
这里的参数ValueType是一个重要的设置。如MicroSoft documnetation中所述:
如果您使用ARM模板自动部署,并且您的逻辑应用程序工作流包括使用托管标识的托管连接器触发器或操作,请确认基础连接资源定义包括参数ValueType属性,并将Alternative作为属性值。否则,您的ARM部署将不会将连接设置为使用托管身份进行身份验证...
该连接随后被逻辑应用程序引用,并包括作为资源ID的标识:
"$connections": {
"value": {
"azureeventgrid": {
"connectionId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Web/connections/', variables('eventApiConnectionName'))]",
"connectionName": "[variables('eventApiConnectionName')]",
"connectionProperties": {
"authentication": {
"type": "ManagedServiceIdentity",
"identity": "[parameters('userManagedIdentity')]"
}
},
"id": "[concat('/subscriptions/',subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureeventgrid')]"
}
}
}
请注意,在事件网格连接的authentication
部分中添加了identity
字段。
有关这方面的更多信息,请参阅Microsoft文档:https://docs.microsoft.com/en-us/azure/logic-apps/create-managed-service-identity?tabs=consumption#create-user-assigned-identity-in-an-arm-template-consumption-only
IDENTITY值应为托管标识的ID。您可以通过Azure门户查看托管身份的JSON视图。这篇关于带有托管身份的事件网格API连接的ARM模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!