Search code examples
azure-data-factoryazure-logic-apps

How to configure Azure Logic Apps to Execute Azure Data Factory on specific date


I am extremely new to Azure Logic Apps, but I've been told that Azure Data Factory is not capable handling complex scheduling.

Therefore, I have create an Azure Logic App service, I have made a start, but I am completely lost.

I am trying to trigger an Azure Data Factory pipeline based on the following date

Last Month End but one e.g. 30/04/2023

I thought this would be easy to create a Trigger for this in ADF, but it looks like I need to use Logic Apps.

enter image description here

Any help most welcomed.


Solution

  • The UX way I would go for: ux way is easier

    {
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Condition": {
                "actions": {},
                "else": {
                    "actions": {
                        "show_last_month_date": {
                            "inputs": {
                                "name": "demo value",
                                "value": "@{subtractFromTime(startOfMonth(addToTime(utcNow(),1,'month')),1,'day')}"
                            },
                            "runAfter": {},
                            "type": "SetVariable"
                        }
                    }
                },
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('LHS')",
                                "@variables('RHS')"
                            ]
                        }
                    ]
                },
                "runAfter": {
                    "demo": [
                        "Succeeded"
                    ]
                },
                "type": "If"
            },
            "day_of_month": {
                "inputs": {
                    "variables": [
                        {
                            "name": "LHS",
                            "type": "integer",
                            "value": "@int(dayOfMonth(utcNow()))"
                        }
                    ]
                },
                "runAfter": {
                    "last_day_of_month": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "demo": {
                "inputs": {
                    "variables": [
                        {
                            "name": "demo value",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "day_of_month": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            },
            "last_day_of_month": {
                "inputs": {
                    "variables": [
                        {
                            "name": "RHS",
                            "type": "integer",
                            "value": "@int(formatDateTime(subtractFromTime(startOfMonth(addToTime(utcNow(),1,'month')),1,'day'),'dd'))"
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "Recurrence_daily": {
                "recurrence": {
                    "frequency": "Day",
                    "interval": 1,
                    "schedule": {
                        "hours": [
                            "1"
                        ],
                        "minutes": [
                            10
                        ]
                    },
                    "startTime": "2023-06-06T12:00:00Z",
                    "timeZone": "UTC"
                },
                "type": "recurrence"
            }
        }
    },
    "parameters": {} }
    

    The code wise wise way to achieve this:

    • The following example is available in MS shows how to update the trigger definition so that the trigger runs only once on the last day of each month:

       "triggers": {
       "Recurrence": {
           "recurrence": {
               "frequency": "Month",
               "interval": 1,
               "schedule": {
                   "monthDays": [-1]
               }
           },
           "type": "Recurrence"
       }
      

      }

    Take a look at the below as well: https://github.com/MicrosoftDocs/azure-docs/issues/26707