# Azure Logic App Action Functions

**URL:** <https://discuss.hashicorp.com/t/azure-logic-app-action-functions/58490>\
**Category:** Azure\
**Created:** [September 22, 2023, 4:56pm UTC](https://discuss.hashicorp.com/t/azure-logic-app-action-functions/58490 "2023-09-22T16:56:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nat-ray](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/nat-ray/32/35828_2.png) [@nat-ray](https://discuss.hashicorp.com/u/nat-ray)\
**Post date:** [September 22, 2023, 4:56pm UTC](https://discuss.hashicorp.com/t/azure-logic-app-action-functions/58490/1 "2023-09-22T16:56:31Z")

</div>

I am facing an issue with Terraform 1.2.6 when trying to create an Azure logic app. I have it set up like this:

```auto
# Define the logic app

resource "azurerm_logic_app_workflow" "generic_app" {
  name = "generic_app" 
  location = azurerm_resource_group.rg.location
  resource_group_name = azurerm_resource_group.rg.name
  identity {
    type = "SystemAssigned"
  }
}

# Run the logic app every 5 minutes

resource "azurerm_logic_app_trigger_custom" "generic_app_trigger" {
  name = "generic_app_name"
  logic_app_id = azurerm_logic_app_workflow.generic_app.id

  body = <<BODY
{
  "recurrence": {
    "frequency": "Minute",
    "interval": 5
  },
  "type": "Recurrence"
}
BODY

}

# Perform the first action

resource "azurerm_logic_app_action_http" "generic_app_action_1" {
  name = "HTTP"
  logic_app_id = azurerm_logic_app_workflow.generic_app.id
  method = "POST"
  uri = "https://some-endpoint.com"
  headers = {
    "authorization" = data.azurerm_key_vault_secret.authtoken_secret.value
    "content-type" = "application/x-www-form-urlencoded"
  }
}

# Perform the second action if the first action completed

resource "azurerm_logic_app_action_http" "generic_app_action_2" {
  name = "HTTP_1"
  logic_app_id = azurerm_logic_app_workflow.generic_app.id
  depends_on = [azurerm_logic_app_action_http.generic_app_action_1]
  method = "POST"
  uri = "https://some-endpoint.com"
  body = "@decodeBase64(triggerBody()?['ContentData'])"
 
  headers = {
    "api-key" = data.azurerm_key_vault_secret.api_key_secret.value
    "Authorization" = "Bearer @{body('HTTP').access_token}"
    "Accept" = "application/json"
    "Content-Type" = "application/json"
  }
  run_after {
    action_name = "HTTP"
    action_result = "Succeeded"
  }
}

```

The terraform apply is successful, but in the Logic App Designer the `HTTP_1` action body (`@decodeBase64(triggerBody()?['ContentData'])`) does not appear correctly:

![screenshot-1](https://global.discourse-cdn.com/hashicorp/original/3X/4/a/4aed6974d1a7d54e8fa008d37297bf0c807d94ff.png)

Instead it should be using the decodeBase64 function and appear like this:

![screenshot-2](https://global.discourse-cdn.com/hashicorp/original/3X/4/e/4e1b65554f7b2305361461e7c3ed2f7691e9729f.png)

![screenshot-3](https://global.discourse-cdn.com/hashicorp/original/3X/4/7/47c9b70abd71b896b4607e7b037d895bd94063e1.png)

I have also tried using a `azurerm_logic_app_action_custom` resource block instead:

```auto
resource "azurerm_logic_app_action_custom" "generic_app_action_2" {
  name = "HTTP_1"
  logic_app_id = azurerm_logic_app_workflow.generic_app.id
  depends_on = [azurerm_logic_app_action_http.generic_app_action_1]

  body = <<BODY
{
  "type": "Http",
  "inputs": {
    "method": "POST",
    "uri": "https://some-endpoint.com",
    "body": {
      "ContentData": "@{decodeBase64(triggerBody()?['ContentData'])}"
    },
    "headers": {      
      "Authorization": "Bearer @{body('HTTP').access_token}",
      "Accept": "application/json",
      "Content-Type": "application/json"
    }
  },
  "runAfter": {
    "HTTP": ["Succeeded"]
  }
}
BODY
}

```

But this is also not working. Is there a way to define functions? Or is this a bug?
