0
votes

I have a Azure logic app defined to clean up old records in the database. Normally if we run the query directly it will take around 5 to 10 mins as it has more records

We are using SQL connector with action execute a SQL query for a cleanup.

I get the 504, Gateway timeout error after 10 mins, We tried to increase a DTU to 1600 from 100 but no luck. Below is the error and the logic app code we use.

How can we increase timeout or achieve the same cleanup better in Azure SQL?

Error

{
  "error": {
    "code": 504,   
    "message": "BadGateway",
    "innerError": {
      "status": 504,
      "message": "Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.\r\nclientRequestId: someid",
      "error": {
        "message": "Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."
      }
    }
  }
}

Logic App Configuration Code

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Execute_a_SQL_query_(V2)": {
                "inputs": {
                    "body": {
                        "query": "DELETE dbo.Messages where RecordStamp < GETDATE()-15"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sql']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/query/sql"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "recurrence": {
                    "frequency": "Day",
                    "interval": 1,
                    "schedule": {
                        "hours": [
                            "0"
                        ]
                    }
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "sql": {
                    "connectionId": "/subscriptions/someid/resourceGroups/prod-rg/providers/Microsoft.Web/connections/sql",
                    "connectionName": "sql",
                    "id": "/subscriptions/someid/providers/Microsoft.Web/locations/westeurope/managedApis/sql"
                }
            }
        }
    }
}