Send email notification on stop VM scheduled (using strat/stop VM V2)

Morsi MASMOUDI 46 Reputation points
2023-08-21T13:41:43.1666667+00:00

I have multiple customer VMs, and I have scheduled them to shut down at a specific time.

User's image

I want to send a notification email to each client 30 minutes before their VM is shut down.

VM1 --> ******@email.com : send email notification to client1 30 min befor shutdown

VM2 --> ******@email.com : send email notification to client2 30 min befor shutdown

....

I saw that I can use the monitoring option (https://learn.microsoft.com/en-us/azure/azure-functions/start-stop-vms/manage), but I'm concerned that i cant filter by VM or send to a specific email for each VM...

Thanks for your help.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,936 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VasimTamboli 5,215 Reputation points
    2023-08-24T09:00:05.1766667+00:00

    Here's a high-level suggestion from my end if i understood your issue correctly.

    Azure Logic App: Create an Azure Logic App that will be triggered at a specific time (30 minutes before the scheduled VM shutdown time). Inside the Logic App, you can use the "Recurrence" trigger along with the "Delay" action to achieve the timing.

    Get VM Shutdown Schedule: Use the "Azure Automation" connector within the Logic App to retrieve the VMs' shutdown schedules. This connector enables you to interact with the start/stop VM schedules you've configured.

    Loop through VMs: After getting the VMs' shutdown schedules, you'll loop through each VM to get its details (name, client email, etc.).

    Send Email: Use the "Office 365 Outlook" connector within the Logic App to send an email to each client. In the email content, you can specify the VM's details and the notification about the upcoming shutdown.

    Here's a basic outline of how you might structure the Logic App:

    Trigger: Use the "Recurrence" trigger to run the Logic App at the desired interval (30 minutes before VM shutdown time).

    Get VM Shutdown Schedule: Use the "Azure Automation" connector to get the shutdown schedule of VMs.

    For Each: Loop through each VM in the schedule.

    Compose Email Content: Inside the loop, use the "Compose" action to create the content of the email. You can include the VM details and the notification message.

    Send Email: Use the "Office 365 Outlook" connector to send an email to the client's email address. You can use dynamic content from the loop (VM details) to customize the email content.

    By using this approach, you can send customized email notifications to each client 30 minutes before their VM is shut down. The Azure Logic App will handle the scheduling and email sending process for you.

    Keep in mind that this is a high-level overview, and you will need to dive into the specifics of setting up the Logic App, configuring connectors, and designing the workflow according to your needs.

    1 person found this answer helpful.
    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.