Adding pre-actions to schedules in Start/Stop VMs v2
Pre-actions are a set of actions in Start/Stop VMs v2 that execute before scheduled start or stop actions. Some scenarios for using pre-actions before a start or stop action include:
- Create a backup of an Azure SQL Database.
- Send a message to Azure Application Insights.
- Call an external API.
Because Start/Stop VMs v2 uses Azure Logic Apps to manage its schedules, it's easy to add one or more pre-actions before the main action. To learn more about Logic Apps, see the Logic Apps documentation.
This article describes how to use the Logic Apps Designer in the Azure portal to add an HTTP request pre-action to an existing scheduled start action in Start/Stop VMs v2. In your implementation, the pre-action can be any action supported by Logic Apps.
Note
At this time, Start/Stop VMs v2 only supports pre-actions, which are run before the execution of the main action. Because Log Apps runs Start/Stop VMs v2 actions asynchronously, there's currently no way to trigger a post-action that occurs after the main action completes.
Prerequisites
You must first complete the steps in Deploy Start/Stop VMs v2 to an Azure subscription, or else complete a default deployment from the Start Stop V2 Deployments GitHub repository. Logic app and action names are based on the ones in a default deployment of Start/Stop VMs v2.
Create an HTTP request pre-action
The steps in this section require the ststv2_vms_Scheduled_start
logic app that was created and deployed when you completed the deployment article. However, the same basic process is used for all scheduled actions.
In the Azure portal, search for and navigate to the resource group you created when you deployed Start/Stop VMs v2.
In the resource group, choose the logic app named
ststv2_vms_Scheduled_start
, which represents the default scheduled start action.In Overview page of the logic app, select Edit.
In the Logic Apps Designer page, select Function-Try and then select Add an action.
Choose HTTP, select the HTTP Method, and add the URL. This HTTP request will be the pre-action for the scheduled start action, after you change the action order in Function-Try. You can also configure the HTTP action at a later time.
Drag the Scheduled action below the new HTTP action in the Function-Try step. The pre-action must come before the scheduled action in the step. Your app should now look like the following example:
At this point, you've defined a pre-action that's run before the start action scheduled by ststv2_vms_Scheduled_start
.
Next steps
If you have issues working with Start/Stop VMs v2, see the Troubleshoot Guide. For more assistance, you can also create an issue in the Start Stop V2 Deployments GitHub repository.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for