In this post, I will show you how easy you can configure the Auto-Shutdown setting to send a notification on Microsoft Teams.
- A valid Azure Subscription
- An Azure VM
- An Azure Logic App
The most important part of this post is the Azure Logic App because it will trigger the flow to send the message to the MS Teams channel.
In our flow, we need an HTTP trigger and a Post Message in a chat or a channel action. The image below shows exactly what we need for our flow in the Logic App.
Steps to build the flow in the Logic App
Step 1. Create the Logic App
Select to Create a logic app, fill in the necessary fields and click the Review + Create button.
|Subscription||Select a valid Azure subscription|
|Resource group||Select a valid resource group or create a new one.|
|Logic app name||Type a name for the logic app|
|Region||Select a region to deploy the logic app|
Step 2. Create the Logic App flow
Choose to create a Blank Logic App
Select “When a HTTP request is received“. This first step will trigger the logic app flow using an HTTP request.
Copy and paste into the Request Body JSON Schema box the JSON schema above and click Save.
By clicking Save, the trigger will generate the webhook URL you need for the auto-shutdown feature.
Step 3. Configure the MS Teams connector
select the “Post message in a chat or channel (Preview)“.
|Post as||Select Flow bot|
|Post in||Select Channel|
|Team||Select a Team|
|Message||Type the message and select the values from the Dynamic content|
Step 4. Configure the Auto-shutdown setting and wait for the flow to run.
From the Azure Portal, go to the Azure VM – Operations – Auto-shutdown,
- enable the setting,
- set the preferred time in the “Scheduled shutdown” field
- set the “Send notification before auto-shutdown?” to Yes
- paste the URL into the “Webhook URL” field and click Save.
Step 5. Try it out
The final step is to try out the Logic App flow and check if it works. If everything went as it has to, then you will see a notification in your MS Teams channel, as the image below shows.