skip to Main Content

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

2

Answers


  1. Your code wouldn’t work because a value cannot be greater than ‘1201’ and less than ‘0101’ at the same time.

    Why don’t you just check the months without checking the dates? Something like this:

    @contains(createArray('03', '04', '12'), utcNow('MM'))
    

    You can’t use this check in the Recurrence trigger, but you can have a Condition action immediately after.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search