Create unbounded Logic Apps timer jobs
{"name": "[parameters('createtimerjoblogicappname')]", "type": "microsoft.logic/workflows", "location": "[parameters('location')]", "tags": {"displayname": "logicapp"}, "apiversion": "2019-05-01", "dependson": ["[resourceid('microsoft.logic/workflows", parameters('timerjoblogicappname'))]"], "properties": {"state": "enabled", "definition": {"$schema": "https://schema.management.azure.com/providers/microsoft.logic/schemas/2016-06-01/workflowdefinition.json#", "contentversion": "1.0.0.0", "triggers": {"manual": {"correlation": {"clienttrackingid": "@triggerbody()["timerjobid"]"}, "type": "request", "kind": "http", "inputs": {"schema": {"properties": {"jobrecurrence": {"properties": {"count": {"minimum": -1, "title": "count (jobrecurrence)", "type": "integer"}, "endtime": {"title": "endtime (jobrecurrence)", "type": "string"}, "frequency": {"enum": ["second", "minute", "hour", "day", "week", "month"], "title": "frequency (jobrecurrence)", "type": "string"}, "interval": {"title": "interval (jobrecurrence)", "type": "integer"}}, "required": ["frequency", "interval"], "type": "object"}, "jobstatus": {"properties": {"executioncount": {"title": "executioncount (jobstatus)", "type": "integer"}, "faultedcount": {"title": "faultedcount (jobstatus)", "type": "integer"}, "lastexecutiontime": {"title": "lastexecutiontime (jobstatus)", "type": "string"}, "nextexecutiontime": {"title": "nextexecutiontime (jobstatus)", "type": "string"}}, "type": "object"}, "starttime": {"type": "string"}, "timerjobid": {"type": "string"}}, "required": ["jobrecurrence", "timerjobid"], "type": "object"}}}}, "actions": {"if_not_past_endtime_or_exceeds_count": {"actions": {"catch_timerjob_error": {"actions": {"terminate_failed_to_create_job": {"runafter": {"timer_job_failed_response": ["succeeded"]}, "type": "terminate", "inputs": {"runerror": {"message": "failed to create timer job"}, "runstatus": "failed"}}, "timer_job_failed_response": {"type": "response", "kind": "http", "inputs": {"body": "failed to create timer job", "statuscode": 400}}}, "runafter": {"timerjob": ["failed", "timedout"]}, "type": "scope"}, "created_response": {"runafter": {"timerjob": ["succeeded"]}, "type": "response", "kind": "http", "inputs": {"body": "next execution time will be at @{variables('nexttime')}", "statuscode": 201}}, "timerjob": {"type": "workflow", "inputs": {"body": {"jobrecurrence": {"count": "@triggerbody()?["jobrecurrence"]?["count"]", "endtime": "@triggerbody()?["jobrecurrence"]?["endtime"]", "frequency": "@triggerbody()?["jobrecurrence"]?["frequency"]", "interval": "@triggerbody()?["jobrecurrence"]?["interval"]"}, "jobstatus": {"executioncount": "@triggerbody()?["jobstatus"]?["executioncount"]", "faultedcount": "@triggerbody()?["jobstatus"]?["faultedcount"]", "lastexecutiontime": "@triggerbody()?["jobstatus"]?["lastexecutiontime"]", "nextexecutiontime": "@variables('nexttime')"}, "starttime": "@triggerbody()?["starttime"]", "timerjobid": "@triggerbody()["timerjobid"]"}, "host": {"triggername": "manual", "workflow": {"id": "[resourceid('microsoft.logic/workflows",parameters('timerjoblogicappname'))]"}}}}}, "runafter": {"initialize_nexttime": ["succeeded"]}, "else": {"actions": {"cancelled": {"runafter": {"exceeded_criteria_response": ["succeeded"]}, "type": "terminate", "inputs": {"runstatus": "cancelled"}}, "exceeded_criteria_response": {"type": "response", "kind": "http", "inputs": {"body": "job completion criteria met.\ndetails: \neither\nendtime(@{triggerbody()?["jobrecurrence"]?["endtime"]}) < next execution time(@{variables('nexttime')})\nor\ncount(@{triggerbody()?["jobrecurrence"]?["count"]}) > execution count (@{triggerbody()?["jobstatus"]?["executioncount"]})", "statuscode": 409}}}}, "expression": {"and": [{"or": [{"equals": ["@coalesce(triggerbody()?["jobrecurrence"]?["endtime"],-1)", -1]}, {"less": ["@variables('nexttime')", "@{triggerbody()?["jobrecurrence"]?["endtime"]}"]}]}, {"or": [{"equals": ["@coalesce(triggerbody()?["jobrecurrence"]?["count"],-1)", -1]}, {"greater": ["@coalesce(triggerbody()?["jobrecurrence"]?["count"],1)", "@coalesce(triggerbody()?["jobstatus"]?["executioncount"],0)"]}]}]}, "type": "if"}, "initialize_nexttime": {"runafter": {"initialize_starttime": ["succeeded"]}, "type": "initializevariable", "inputs": {"variables": [{"name": "nexttime", "type": "string", "value": "@{addtotime(coalesce(triggerbody()?["jobstatus"]?["lastexecutiontime"],variables('starttime')),triggerbody()["jobrecurrence"]["interval"],triggerbody()["jobrecurrence"]["frequency"])}"}]}}, "initialize_starttime": {"type": "initializevariable", "inputs": {"variables": [{"name": "starttime", "type": "string", "value": "@{if(less(coalesce(triggerbody()?["starttime"],utcnow()),utcnow()),utcnow(),coalesce(triggerbody()?["starttime"],utcnow()))}"}]}}}}}}{"name": "[parameters('timerjoblogicappname')]", "type": "microsoft.logic/workflows", "location": "[parameters('location')]", "tags": {"displayname": "logicapp"}, "apiversion": "2019-05-01", "properties": {"state": "enabled", "definition": {"$schema": "https://schema.management.azure.com/providers/microsoft.logic/schemas/2016-06-01/workflowdefinition.json#", "contentversion": "1.0.0.0", "triggers": {"manual": {"correlation": {"clienttrackingid": "@triggerbody()["timerjobid"]"}, "type": "request", "kind": "http", "inputs": {"schema": {"properties": {"jobrecurrence": {"properties": {"count": {"minimum": -1, "title": "count (jobrecurrence)", "type": "integer"}, "endtime": {"title": "endtime (jobrecurrence)", "type": "string"}, "frequency": {"enum": ["second", "minute", "hour", "day", "week", "month"], "title": "frequency (jobrecurrence)", "type": "string"}, "interval": {"title": "interval (jobrecurrence)", "type": "integer"}}, "required": ["frequency", "interval"], "type": "object"}, "jobstatus": {"properties": {"executioncount": {"title": "executioncount (jobstatus)", "type": "integer"}, "faultedcount": {"title": "faultedcount (jobstatus)", "type": "integer"}, "lastexecutiontime": {"title": "lastexecutiontime (jobstatus)", "type": "string"}, "nextexecutiontime": {"title": "nextexecutiontime (jobstatus)", "type": "string"}}, "required": ["nextexecutiontime"], "type": "object"}, "starttime": {"type": "string"}, "timerjobid": {"type": "string"}}, "required": ["timerjobid", "jobrecurrence", "jobstatus"], "type": "object"}}}}}}} 