- You can also look at conditionals in order to achieve this requirement. The following is a demonstration for a pipeline (which will be scheduled to run every day) which executes the required pipeline on last but one day of every month.
- I have taken 2 array parameters with pre-defined last but one day of each month in the format
dd/MM
, one parameter of the leap year case and another for normal year (As last but one day for Feb in leap year would be different):
last_but_one_ends: ["30/01","27/02","30/03","29/04","30/05","29/06","30/07","30/08","29/09","30/10","29/11","30/12"]
last_but_one_ends_leap_yr: ["30/01","28/02","30/03","29/04","30/05","29/06","30/07","30/08","29/09","30/10","29/11","30/12"]
- Now, using set variable as an if condition, I check if its leap year or not (divisible by 4).
@if(equals(mod(int(formatDateTime(utcNow(),'yyyy')),4),0),'ok',0)

- Now, based on the outcome of this, I have if condition activities that check the respective condition. It checks whether the current date (dd/MM format) is present in
last_but_one_ends
if its not a leap year and in last_but_one_ends_lear_yr
if its a leap year.

- Call the required pipeline when this above condition gives true and ignore the false case. The following is an debug output for today's date.

- Schedule this pipeline to run daily. You can also schedule this pipeline to run only on the last 5 days in the schedule trigger settings as your required dates fall within this span.

- Pipeline JSON (without trigger attached):
{
"name": "pipeline2",
"properties": {
"activities": [
{
"name": "get day and month",
"type": "SetVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "date",
"value": {
"value": "@formatDateTime(utcnow(),'dd/MM')",
"type": "Expression"
}
}
},
{
"name": "if to check leap year",
"type": "SetVariable",
"dependsOn": [
{
"activity": "get day and month",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "year",
"value": {
"value": "@if(equals(mod(int(formatDateTime(utcNow(),'yyyy')),4),0),'ok',0)",
"type": "Expression"
}
}
},
{
"name": "not leap year",
"type": "IfCondition",
"dependsOn": [
{
"activity": "if to check leap year",
"dependencyConditions": [
"Failed"
]
}
],
"userProperties": [],
"typeProperties": {
"expression": {
"value": "@contains(pipeline().parameters.last_but_one_ends,variables('date'))",
"type": "Expression"
},
"ifTrueActivities": [
{
"name": "Execute Pipeline1",
"type": "ExecutePipeline",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"pipeline": {
"referenceName": "pipeline1",
"type": "PipelineReference"
},
"waitOnCompletion": true
}
}
]
}
},
{
"name": "leap_year",
"type": "IfCondition",
"dependsOn": [
{
"activity": "if to check leap year",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"expression": {
"value": "@contains(pipeline().parameters.last_but_one_ends_leap_yr,variables('date'))",
"type": "Expression"
},
"ifTrueActivities": [
{
"name": "Execute Pipeline2",
"type": "ExecutePipeline",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"pipeline": {
"referenceName": "pipeline1",
"type": "PipelineReference"
},
"waitOnCompletion": true
}
}
]
}
}
],
"parameters": {
"last_but_one_ends": {
"type": "array",
"defaultValue": [
"30/01",
"27/02",
"30/03",
"29/04",
"30/05",
"29/06",
"30/07",
"30/08",
"29/09",
"30/10",
"29/11",
"30/12"
]
},
"last_but_one_ends_leap_yr": {
"type": "array",
"defaultValue": [
"30/01",
"28/02",
"30/03",
"29/04",
"30/05",
"29/06",
"30/07",
"30/08",
"29/09",
"30/10",
"29/11",
"30/12"
]
}
},
"variables": {
"date": {
"type": "String"
},
"year": {
"type": "String"
}
},
"annotations": []
}
}