How can I stop VMs on weekends using Start/Stop VMs v2 in Azure?

Enes 40 Reputation points
2025-07-04T09:13:56.38+00:00

Hi all, I'm using Start/Stop VMs v2 in Azure to automate virtual machine scheduling. I've successfully configured Logic Apps to start and stop VMs during business hours, but I'm struggling with excluding weekends entirely from the schedule.

The recurrence in the Logic App only allows setting the hours but not specific days of the week to run. Ideally, I want the VMs to:

  • Start at 8:00 AM and stop at 6:00 PM only Monday to Friday
  • Remain completely stopped on Saturday and Sunday

From my understanding of the documentation, there's no direct support for day-based exclusion in the recurrence trigger. Is there a recommended workaround to implement this behavior (e.g., using multiple schedules, conditions in Logic App, or custom implementation)?

Any help or examples would be appreciated!

Thanks!

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,563 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Krishna Chowdary Paricharla 805 Reputation points Microsoft External Staff Moderator
    2025-07-04T09:32:37.4133333+00:00

    Hello Enes,

    Since the Logic App recurrence trigger doesn’t directly support day-of-week filtering, you can handle it using the "Condition" control and some basic logic.

    Option 1: Use a Condition in Logic App to Check Day of Week

    Keep the recurrence trigger running every weekday at 8:00 AM and 6:00 PM.

    Add a "Condition" step immediately after the trigger:

    Use @dayOfWeek(utcNow()) to get the current day:

         Monday = 1, ..., Friday = 5, Saturday = 6, Sunday = 0
         
            Example condition:
            
            ```sql
            json
            Copy
            @and(greaterOrEquals(dayOfWeek(utcNow())
            ```
            
               If true → proceed to start/stop VM actions.
               
                  If false → do nothing (weekend).
                  
    

    Utilizing a single Logic App is sufficient for this requirement.

    Option 2: Separate Recurrence Triggers for Each Weekday

    Create 5 recurrence triggers in the Logic App—one for each day (Mon–Fri).

    Each trigger can be set to run at 8:00 AM or 6:00 PM on its respective day.

    With option 2, there are no required conditions; scheduling is handled visually in a straightforward manner.

    For your reference, please go through this following documentation:
    Logic apps dayOfWeek

    Hope this helps!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.