I have an ARM template that will deploy an Event Grid Custom Topic and Logic App and wire up a subscription using a Managed Identity.
The ARM template is:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workflows_lgeventgridtriggermaindev_name": {
"type": "String"
},
"topics_eglogicappscratchtestdev_externalid": {
"type": "String"
},
"topics_eglogicappscratchtestdev_name": {
"type": "String"
},
"topics_eglogicappscratchtestdev_lgsubscriptionName": {
"type": "String"
},
"LogicAppLocation": {
"type": "string",
"minLength": 1,
"defaultValue": "northeurope"
},
"azureeventgrid_1_Connection_Name": {
"type": "string",
"defaultValue": "azureeventgrid"
},
"azureeventgrid_1_Connection_DisplayName": {
"type": "string",
"defaultValue": "lgapiegscratch"
}
},
"variables": {
"targetLogicApp": {
"triggerId": "[resourceId('Microsoft.Logic/workflows/triggers', parameters('workflows_lgeventgridtriggermaindev_name'), 'When_a_resource_event_occurs')]"
}
},
"resources": [
{
"type": "Microsoft.EventGrid/topics",
"apiVersion": "2021-06-01-preview",
"name": "[parameters('topics_eglogicappscratchtestdev_name')]",
"location": "uksouth",
"sku": {
"name": "Basic"
},
"kind": "Azure",
"identity": {
"type": "None"
},
"properties": {
"inputSchema": "EventGridSchema",
"publicNetworkAccess": "Enabled"
}
},
{
"type": "MICROSOFT.WEB/CONNECTIONS",
"apiVersion": "2018-07-01-preview",
"name": "[parameters('azureeventgrid_1_Connection_Name')]",
"location": "[parameters('LogicAppLocation')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('LogicAppLocation'), '/managedApis/', 'azureeventgrid')]"
},
"displayName": "[parameters('azureeventgrid_1_Connection_DisplayName')]",
"parameterValueType": "Alternative"
}
},
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('workflows_lgeventgridtriggermaindev_name')]",
"location": "[parameters('LogicAppLocation')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"state": "Enabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"getTopicData": {
"type": "Compose",
"inputs": "@triggerBody()?['data']",
"runAfter": {}
}
},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_resource_event_occurs": {
"type": "ApiConnectionWebhook",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureeventgrid']['connectionId']"
}
},
"body": {
"properties": {
"topic": "[parameters('topics_eglogicappscratchtestdev_externalid')]",
"destination": {
"endpointType": "webhook",
"properties": {
"endpointUrl": "@{listCallbackUrl()}"
}
},
"filter": {
"includedEventTypes": [
"TriggerLogicApp"
],
"subjectBeginsWith": "Main"
}
}
},
"path": "[concat('/subscriptions/@{encodeURIComponent(''', subscription().subscriptionId, ''')}/providers/@{encodeURIComponent(''Microsoft.EventGrid.Topics'')}/resource/eventSubscriptions')]",
"queries": {
"x-ms-api-version": "2017-06-15-preview"
}
},
"splitOn": "@triggerBody()"
}
},
"contentVersion": "1.0.0.0",
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azureeventgrid": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('LogicAppLocation'), '/managedApis/', 'azureeventgrid')]",
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('azureeventgrid_1_Connection_Name'))]",
"connectionName": "[parameters('azureeventgrid_1_Connection_Name')]",
"connectionProperties": {
"authentication": {
"type": "ManagedServiceIdentity"
}
}
}
}
}
}
},
"tags": {
"displayName": "LogicApp"
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('azureeventgrid_1_Connection_Name'))]",
"[resourceId('Microsoft.EventGrid/topics', parameters('topics_eglogicappscratchtestdev_name'))]"
]
},
{
"name": "[parameters('topics_eglogicappscratchtestdev_lgsubscriptionName')]",
"scope": "[format('Microsoft.EventGrid/topics/{0}', parameters('topics_eglogicappscratchtestdev_name'))]",
"type": "Microsoft.EventGrid/eventSubscriptions",
"location": "[parameters('LogicAppLocation')]",
"apiVersion": "2020-04-01-preview",
"properties": {
"destination": {
"endpointType": "WebHook",
"properties": {
"endpointUrl": "[listCallbackUrl(variables('TargetLogicApp').triggerId, '2019-05-01').value]"
}
},
"filter": {
"subjectBeginsWith": "Main",
"includedEventTypes": [
"TriggerLogicApp"
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('azureeventgrid_1_Connection_Name'))]"
]
}
]
}
An example parameters file is:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"workflows_lgeventgridtriggermaindev_name": {
"value": "lgeventgridtriggerscratch"
},
"topics_eglogicappscratchtestdev_externalid": {
"value": "/subscriptions/<subscriptionid>/resourceGroups/<resourcegroupname>/providers/Microsoft.EventGrid/topics/eglogicappscratch"
},
"topics_eglogicappscratchtestdev_name": {
"value": "eglogicappscratch"
},
"topics_eglogicappscratchtestdev_lgsubscriptionName": {
"value": "lgeventgridtriggerscratchsub"
},
"LogicAppLocation": {
"value": "uksouth"
},
"azureeventgrid_1_Connection_Name": {
"value": "azureeventgrid"
},
"azureeventgrid_1_Connection_DisplayName": {
"value": "lgapiegscratch"
}
}
}
When I load this template into the Visual Studio 2019 Logic App designer I get an issue I've documented here:
Visual Studio 2019 Logic Apps Designer removing code