Terraform-provider-azurerm: Action groups not triggering Logic Apps

Created on 10 Mar 2020  路  6Comments  路  Source: terraform-providers/terraform-provider-azurerm

Terraform (and AzureRM Provider) Version

Terraform v0.12.21
Provider v1.44.0

Affected Resource(s)

  • azurerm_monitor_action_group

Terraform Configuration Files

resource "azurerm_monitor_action_group" "alerting-ag" {

  for_each = var.go-monitors

  name                = "${local.name-prefix}-${each.key}-ag-001"
  resource_group_name = data.terraform_remote_state.hub-setup.outputs.alerts-rg.resource-group-name
  short_name          = each.value.short-name

  logic_app_receiver {
    name                    = azurerm_logic_app_workflow.logicapp[each.key].name
    resource_id           = azurerm_logic_app_workflow.logicapp[each.key].id
    callback_url           = azurerm_logic_app_workflow.logicapp[each.key].access_endpoint
    use_common_alert_schema    = true

  }
}

Expected Behavior

Azure alerts comes in, the action group related to alert should trigger the Logic App associated to the action group.

Actual Behavior

As the Azure alerts are being fired, the action groups are not firing the Logic Apps. This is until, I manually disable and re-enable the "common alert schema" inside each of Action group, then the Logic Apps start firing once the next alert fires.

bug servicmonitor

Most helpful comment

Could this issue turn into feature request possibly? So that callback_url could retrieve the necessary full HTTP trigger from the logic app.

All 6 comments

Confirmed. Sometimes, besides only enabling and disabling the _common alert schema_, I also need to make any manual change in the Logic app code and save it (it can be meaningless, e.g. change some string value in an _HTTP_ step's body). Then it begins triggering.

I can then revert the change manually (go to the Logic Apps version history and promote the older version) and it still triggers.

Hi @mateusz-kozub, i think, that problem is in callback_url. Callback_url must be url of HTTP trigger and not azurerm_logic_app_workflow.logicapp[each.key].access_endpoint, which is missing essential part in url. For better understanding you should check in portal both url and you will see the differences between them. If you are using ARM template for logic app, you can add this output and use it in action group.

Add in ARM template json:
"callbackUrl": {
"type": "string",
"value": "[listCallbackUrl(concat(resourceId(resourceGroup().name,'Microsoft.Logic/workflows', parameters('name')), '/triggers/manual'), '2016-06-01').value]"
}

Add in TF output:
output "logic_app_callback_url" {
value = lookup(azurerm_template_deployment.logic_app.outputs, "callbackUrl", "")
}

I hope, that this will help you.

Hey @SimonGaspar , I can see your point. I am using TF for the logic apps, is there any way for TF to output this?

Maybe you could use powershell with rest api and somehow get what you need. Check this

Ah, that's a bit frustrating. I take a look at your link and see if I can work something out. Hopefully, in future, this could be handled by tf.

Could this issue turn into feature request possibly? So that callback_url could retrieve the necessary full HTTP trigger from the logic app.

Was this page helpful?
0 / 5 - 0 ratings