Start and Stop Azure VMs Using PowerApps, Power Automate(formerly known as Microsoft Flow), SharePoint and Azure Automation - Part 2

Continuing from my previous post, in this one I’ll go through the other two steps of Power Automate(formerly known as Microsoft Flow) and Power Apps.

Power Automate(formerly known as Microsoft Flow)

This is a simple three-step workflow. I am using the Azure Automation connector to call the Azure Automation runbooks to start and stop the VMs.


  1. The Power App initiates the call
  2. Is an Azure Automation connector and the action is Create Job
  3. Then the status is returned to the Power App. The status is the VM power state which is either “running” or “stopped”

Power App

Creating the Power App is as simple you can learn more about Power Apps here. I made use of the Create an app feature on the SharePoint which basically created the app for me and I’ve made a couple of tweaks to make it work for me.

These are some of the key features of the Power App that I’ve added which brings everything together:
  • Dropdown which filters the list by Product. I have different environments which I wish to control. I’ve using the Distinct function on the OnSelect action of the control to filter my list SharePoint.
For Start and Stop button I’m attaching the Flow action control on the OnSelect action of the button. I’m using ";" operator to chain a couple of functions. The first function calls Flow which subsequently calls the Azure automation runbook.
The Set function is used hold assigns the result from the Start or Stop call to the Flow
Lastly, the Notify function is displays the VM state after the Start/Stop VM called.

  • Start button –
    1. StartVM.Run('Resource group_DataCard1'.Default, VM_DataCard1.Default)
    2. Notify(PowerState.status)
  • Stop button -
      1. StopVM.Run('Resource group_DataCard1'.Default, VM_DataCard1.Default)
      2. Notify(PowerState.status)
    And that’s my Power App.


    Comments

    Popular posts from this blog

    Override a System Defined Refresh button in D365O

    Printing PDF Attachments in MSDyn365FO