azurelogicazure-logic-apps

Trying to enable / disable Azure logic app at specific time period


I am currently building a logic app that will turn off a VM during the months of January through March and May through November. The rest of the time, the VM will be turned on. This part of the logic app is working as intended.

A second logic app is requested to turn the VM (during the periods it is supposed to be on) off during the nights and on at the start of the day.

Does anybody know how to trigger the second logic app to enable during the "on season"? I obviously don't want the second logic app to turn on the VM during the periods it is supposed to be turned off.

I would love to hear from you!

My idea is to run:

@or(and(greaterOrEquals(utcNow('MMdd'), '0401', lessOrEquals(utcNow('MMdd'), '0501')(and(greaterOrEquals(utcNow('MMdd'), '1201', lessOrEquals(utcNow('MMdd'), '0101')')

through the occurrence setting, but I have no idea if this will be enough / correct


Solution

  • Recently we had a similar situation of starting and stopping VM's. We used the Azute Automation Service that resolved our needs. The Azure Automation services provides with 2 Logic App that can start and stop VM's. You can also customize these to logic App to your reqiremen. It seems that you need to start/stop of the VM's to work on April and December alone. What I would suggest is to clone the start Logic App created by the Automation Service and then add additional logic to it.

    The details of the Azure Automation Sevice MSDN reference as as below

    A simple and straight forward way will be use the swicth case to check the utcNow('MM') [returns month number as 01, 02, 03 ...12) and perform the start / stop of the VM's. Please see if this helps

    Default Logic Start App enter image description here

    Modified Logic App with Month Condition enter image description here

    If condition with OR filter for month enter image description here