在 Logic App 中通过 ARM 连接器创建子资源
Create a child resource by ARM connector in Logic App
如何使用 Logic App 创建子资源(例如 Blob 存储的容器或 Eventhub 的使用者组)?
要在逻辑应用程序中使用 ARM 连接器创建资源,您需要指定用于构建新服务路径的提供程序和短资源 ID。但是,它们不对应于 ARM 模板中的“类型”和“名称”参数(在示例“Microsoft.Eventhub/namespaces”和“vvtesteventhub”中)。
"inputs": {
"body": {...},
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{variables('subscriptionId')}/resourcegroups/@{variables('resourceGroup')}/providers/Microsoft.EventHub/namespaces/vvtesteventhub",
"queries": {
"x-ms-api-version": "2021-06-01-preview"
}
}
对于子资源,有必要以某种方式构建包含父资源名称的完整路径。但是,即使直接通过代码视图编辑,我也无法构建它(见下文)。 运行 失败并显示错误消息“未找到资源”,尽管它包含指向我要在其中创建使用者组的现有事件中心的正确路径。
{
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{variables('subscriptionId')}/resourcegroups/@{variables('resourceGroup')}/providers/Microsoft.EventHub/namespaces/eventhubs/@{variables('eventhubNamespacesName')}/@{variables('eventhubName')}/consumergroups/@{variables('platformName')}",
"queries": {
"x-ms-api-version": "2021-06-01-preview"
}
}
}
我们已经在本地环境中进行了测试,它运行良好,以下语句基于分析。
在我们的本地环境中,我们创建了一个事件中心命名空间和一个逻辑应用程序。
使用逻辑应用程序Azure resource Manager connector
操作创建或更新资源 我们能够创建 EventHub 并在其中添加一个消费者组。
这是逻辑应用程序:
这是逻辑应用程序的代码视图:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "Microsoft.EventHub/namespaces",
"runAfter": {},
"type": "Compose"
},
"Create_a_ConsumerGroup_to_existing_EventHub": {
"inputs": {
"body": {
"location": "westus"
},
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourcegroups/@{encodeURIComponent('<rgName>')}/providers/@{encodeURIComponent(outputs('Compose'))}/@{encodeURIComponent('/<EventHubNamespacesName>/eventhubs/<EventHubName>/consumergroups/<ConsumerGroupName>')}",
"queries": {
"x-ms-api-version": "2021-11-01"
}
},
"runAfter": {
"Creates_a_EventHub_to_existing_EventHubNamespaces_": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Creates_a_EventHub_to_existing_EventHubNamespaces_": {
"inputs": {
"body": {
"location": "westus"
},
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourcegroups/@{encodeURIComponent('<rgName>')}/providers/@{encodeURIComponent(outputs('Compose'))}/@{encodeURIComponent('/<EventHubNamespacesName>/eventhubs/<EventHubName>')}",
"queries": {
"x-ms-api-version": "2021-11-01"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Hour",
"interval": 3
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"arm": {
"connectionId": "/subscriptions/<sub-id>/resourceGroups/<rgName>/providers/Microsoft.Web/connections/arm",
"connectionName": "arm",
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/eastus/managedApis/arm"
}
}
}
}
}
这里是示例输出以供参考:
注:
要为 EventHub 创建使用者组,您需要有一个现有的 EventHub,或者您需要创建一个新的 Event Hub。
如何使用 Logic App 创建子资源(例如 Blob 存储的容器或 Eventhub 的使用者组)?
要在逻辑应用程序中使用 ARM 连接器创建资源,您需要指定用于构建新服务路径的提供程序和短资源 ID。但是,它们不对应于 ARM 模板中的“类型”和“名称”参数(在示例“Microsoft.Eventhub/namespaces”和“vvtesteventhub”中)。
"inputs": {
"body": {...},
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{variables('subscriptionId')}/resourcegroups/@{variables('resourceGroup')}/providers/Microsoft.EventHub/namespaces/vvtesteventhub",
"queries": {
"x-ms-api-version": "2021-06-01-preview"
}
}
对于子资源,有必要以某种方式构建包含父资源名称的完整路径。但是,即使直接通过代码视图编辑,我也无法构建它(见下文)。 运行 失败并显示错误消息“未找到资源”,尽管它包含指向我要在其中创建使用者组的现有事件中心的正确路径。
{
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{variables('subscriptionId')}/resourcegroups/@{variables('resourceGroup')}/providers/Microsoft.EventHub/namespaces/eventhubs/@{variables('eventhubNamespacesName')}/@{variables('eventhubName')}/consumergroups/@{variables('platformName')}",
"queries": {
"x-ms-api-version": "2021-06-01-preview"
}
}
}
我们已经在本地环境中进行了测试,它运行良好,以下语句基于分析。
在我们的本地环境中,我们创建了一个事件中心命名空间和一个逻辑应用程序。
使用逻辑应用程序Azure resource Manager connector
操作创建或更新资源 我们能够创建 EventHub 并在其中添加一个消费者组。
这是逻辑应用程序:
这是逻辑应用程序的代码视图:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "Microsoft.EventHub/namespaces",
"runAfter": {},
"type": "Compose"
},
"Create_a_ConsumerGroup_to_existing_EventHub": {
"inputs": {
"body": {
"location": "westus"
},
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourcegroups/@{encodeURIComponent('<rgName>')}/providers/@{encodeURIComponent(outputs('Compose'))}/@{encodeURIComponent('/<EventHubNamespacesName>/eventhubs/<EventHubName>/consumergroups/<ConsumerGroupName>')}",
"queries": {
"x-ms-api-version": "2021-11-01"
}
},
"runAfter": {
"Creates_a_EventHub_to_existing_EventHubNamespaces_": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Creates_a_EventHub_to_existing_EventHubNamespaces_": {
"inputs": {
"body": {
"location": "westus"
},
"host": {
"connection": {
"name": "@parameters('$connections')['arm']['connectionId']"
}
},
"method": "put",
"path": "/subscriptions/@{encodeURIComponent('<sub-id>')}/resourcegroups/@{encodeURIComponent('<rgName>')}/providers/@{encodeURIComponent(outputs('Compose'))}/@{encodeURIComponent('/<EventHubNamespacesName>/eventhubs/<EventHubName>')}",
"queries": {
"x-ms-api-version": "2021-11-01"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Hour",
"interval": 3
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"arm": {
"connectionId": "/subscriptions/<sub-id>/resourceGroups/<rgName>/providers/Microsoft.Web/connections/arm",
"connectionName": "arm",
"id": "/subscriptions/<sub-id>/providers/Microsoft.Web/locations/eastus/managedApis/arm"
}
}
}
}
}
这里是示例输出以供参考:
注:
要为 EventHub 创建使用者组,您需要有一个现有的 EventHub,或者您需要创建一个新的 Event Hub。