Skip to main content

Export a single flow to a Logic App

Author: Albert-Jan Schot

Want to upgrade one of your Power Automate flows to a Logic App? Missing the option in the UI? Or just looking at an easy way to do it programmatically?

By combining the CLI for Microsoft 365 and PowerShell we can make this task easy and repeatable.

This script will export the Power Automate flow Your sample test flow, make sure to pass the correct name in the script, and your flow will be exported right away.

Write-Output "Getting environment info..."
$environmentId = $(m365 flow environment list --query "[?displayName == '(default)']" -o json | ConvertFrom-Json).Name
$flowId = $(m365 flow list --environmentName $environmentId --query "[?displayName == 'Your sample test flow']" -o json | ConvertFrom-Json)[0].Name

Write-Output "Getting Flow info..."
m365 flow export --environmentName $environmentId --name $flowId --format 'json'

Write-Output "Complete"