Menu Home

Microsoft Flow and Azure Resource Manager VM monitor

Today Microsoft released new connectors for Microsoft Flow. Normally I wouldn’t care about it, but today’s release contains two interesting connectors for APIs that I care about. One is the PowerBI connector that I’m sure I will find a use for. The other is the Azure Resource Manager connector.

I was a bit surprised to see an Azure Resource Manager connector in a end-user product like Microsoft Flow, but it is probably due to the fact the Flow is built on top of the Logic App platform, so they decided to just give end-users access to the Azure Resource Manager API too.

I doubt that any end user will be able to figure out to do anything with it, and it also comes with no startup templates, but developer savy people like myself will probably build some interesting solutions with it.

I just spend some time playing around with the difference Resource Manager actions
ms-flow-azure-resource-group-connectors

Although the list is long, it is far from complete, compared to what you can do with the ARM API. There are actions for listing subscriptions, resource groups and resources, also actions for updating (PUT) and deleting various resources type, and support for deploying ARM templates (gonna be fun to see what people can do with that, a flow that can be used to request a VM, would be easy to build).

I really wish they had added some generic GET, PUT, POST, DELETE actions, so that I could write my own REST queries, because right now I can’t do post requests as all the update/create actions do PUT requests as far as I can figure out.

The flow I tried to build does the following:

Every day after 18 o’clock it checks if a certain VM is powered off, if not it sends a push notification to the flow app warning me that I forgot to turn of the VM. It also at the same time sends me and approval e-mail from which I can approve the shutdown or reject it. If I approve the shutdown, the machine should power off (deallocate). Unfortunately because of the missing POST actions, I couldn’t implement the last piece with the machine powering off, as that requires a POST to /subscriptions/{subscriptionId}/resourceGroups/ {resourceGroupName}/providers/ Microsoft.Compute/virtualMachines/{vmName} /deallocate?api-version=2016-03-30.

The flow itself, got a little complicated as I had to use the Logic App Workflow Definition Language in a few places. The UI of the flow editor and for that matter also the logic app editor, doesn’t really do justice to all the things you can do with the them. I understand that they are trying to make the UI user friendly, but I think they should consider adding an advanced/expert mode to allow to a more developer tailored experience. Logic Apps have the code view, which is better but something in between would be preferred in my opinion.

Here’s a picture of the flow:
ms-flow-turn-off-vm

The few language definitions I used are:

To only run after 18 o’clock
@greater(int(utcnow('HH')), 18)

To check that the machine is not in the deallocated state
@equals(last(body('Read_a_resource')?['statuses'])?['code'], 'PowerState/deallocated')

To read more about the workflow definition language check msdn.

Categories: Windows Azure

Tagged as:

Simon J.K. Pedersen

Leave a Reply

Your email address will not be published. Required fields are marked *