Terraform-provider-azurerm: Logic App: Add callback url as attribute of http request trigger

Created on 25 Jun 2019  路  8Comments  路  Source: terraform-providers/terraform-provider-azurerm

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description


Please add the ability to make use of the callback url from the ListCallbackURL azure sdk api for a given trigger so that the logic app can be hooked up to other infrastructure.

My particular use case is i'm trying to use terraform to manage the creation of a logic app and a monitor action group that should be configured to trigger that logic app.
I would just set up the action group with a logic app receiver so only the logic app name is necessary, but these are currently not supported either.

New or Affected Resource(s)

  • azurerm_logic_app_trigger_http_request

References

enhancement serviclogic

Most helpful comment

For anyone who finds this later, here's what I ended up doing:
`resource "azurerm_template_deployment" "logic_app_endpoint" {
name = "${var.name}-${var.env}-logic_app_endpoint"
resource_group_name = data.azurerm_resource_group.this.name
deployment_mode = "Incremental"

template_body = < {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"logicApp": {
"name": "${azurerm_logic_app_workflow.this.name}",
"trigger": "http-trigger"
},
"resourceId": "[resourceId('Microsoft.Logic/workflows/triggers', variables('logicApp').name, variables('logicApp').trigger)]",
"apiVersion": "[providers('Microsoft.Logic', 'workflows').apiVersions[0]]"
},
"resources": [],
"outputs": {
"endpointUrl": {
"type": "string",
"value": "[listCallbackUrl(variables('resourceId'), variables('apiVersion')).value]"
}
}
}
DEPLOY

}

resource "azurerm_monitor_action_group" "this" {
name = "${var.name}-${var.env}-ag"
short_name = var.short_name
resource_group_name = data.azurerm_resource_group.this.name

logic_app_receiver {
name = "logic-app-reciever"
resource_id = azurerm_logic_app_workflow.this.id
callback_url = azurerm_template_deployment.logic_app_endpoint.outputs["endpointUrl"]
use_common_alert_schema = true
}
}`

All 8 comments

I too would like this - it seems like a pretty common use case and if it were available we would likely make extensive use of it. This could also apply to any resource which, once created, exposes an endpoint which you might well want to consume within your infrastructure definitions.

hi @AhtiBelvar ,
what do you use to temporary enable this LogicAppReceivers in your deployment ? az powershell ?
can you share your sample here. thanks

Hi!
I had a very similar problem. I wanted to get the "callback_url" from the Provider to be used for an action group (azurerm_monitor_action_group). This Resource wants me to set the "callback_url".
I found this article, where it says, that the logic app itself (azurerm_logic_app_workflow) exposes the "access_endpoint". After looking in Azure Portal I found out that this is the same value as the "callback_url". I will try fixing my problem with that. Maybe this helps you with your problem?
I麓ll come back later to tell you if this fix will help.
https://www.terraform.io/docs/providers/azurerm/r/logic_app_workflow.html#access_endpoint

@ZeroVEVO I have no idea how I missed that, but it looks like exactly what I'm after, thank you! I guess the fact that MS call their function listCallbackUrl and I've seen it referred to as a callback URL in various places meant I was tuned into looking for those words. But from an initial glance I think you are absolutely right and this is the right value. Always seemed strange that it wouldn't be an output from logic apps since it's pretty crucial!

@spettifer That was exacly my first thought about that problem. The names MS gives their functions or the variables in Azure is very strange sometimes.. Im glad I could help.
For me this worked, too. I don麓t know either why this is not an output from the logic_app_action, but from the logic_app itself with a different name.

@ZeroVEVO I have noted however that access_endpoint is only the base URL: The full URL will include the trigger name, the access key and so on, so unfortunately this still isn't adequate as otherwise you have to go and get all those bits of information separately and construct it. Getting the URL of a trigger still requires me to use a hacky workaroudn involving and ARM snippet and a template deployment which has sever limitations (like needing to be re-created on each run to guarantee you actually get the output value). Back to the drawing board.

Yes, the access_endpoint is pretty worthless to me. It is actually deceptive because it looks like exactly what you are looking for... but then you set it up using that as the target from your action group... and proceed to pull your hair out about why your alerts aren't making it to the logic app.

We really need the results of Get-AzureRmLogicAppTriggerCallbackUrl on the azurerm_logic_app_trigger_http_request to be able to pass that into the action group.

If anyone has any nifty workarounds, please share. I think I'm going down the rather ugly azurerm_template_deployment route for now.

For anyone who finds this later, here's what I ended up doing:
`resource "azurerm_template_deployment" "logic_app_endpoint" {
name = "${var.name}-${var.env}-logic_app_endpoint"
resource_group_name = data.azurerm_resource_group.this.name
deployment_mode = "Incremental"

template_body = < {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"logicApp": {
"name": "${azurerm_logic_app_workflow.this.name}",
"trigger": "http-trigger"
},
"resourceId": "[resourceId('Microsoft.Logic/workflows/triggers', variables('logicApp').name, variables('logicApp').trigger)]",
"apiVersion": "[providers('Microsoft.Logic', 'workflows').apiVersions[0]]"
},
"resources": [],
"outputs": {
"endpointUrl": {
"type": "string",
"value": "[listCallbackUrl(variables('resourceId'), variables('apiVersion')).value]"
}
}
}
DEPLOY

}

resource "azurerm_monitor_action_group" "this" {
name = "${var.name}-${var.env}-ag"
short_name = var.short_name
resource_group_name = data.azurerm_resource_group.this.name

logic_app_receiver {
name = "logic-app-reciever"
resource_id = azurerm_logic_app_workflow.this.id
callback_url = azurerm_template_deployment.logic_app_endpoint.outputs["endpointUrl"]
use_common_alert_schema = true
}
}`

Was this page helpful?
0 / 5 - 0 ratings