GitHub Icon Image
GitHub

Export a single flow to a Logic App

Summary

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.

  • CLI for Microsoft 365 using PowerShell
  • CLI for Microsoft 365 using Bash
Write-Output "Getting environment info..."
$environmentId = $(m365 flow environment list --query "[?displayName == '(default)']" -o json | ConvertFrom-Json).Name
$flowId = $(m365 flow list --environment $environmentId --query "[?displayName == 'Your sample test flow']" -o json | ConvertFrom-Json)[0].Name

Write-Output "Getting Flow info..."
m365 flow export --environment $environmentId --id $flowId -f 'json'

Write-Output "Complete"

Check out the CLI for Microsoft 365 to learn more at: https://aka.ms/cli-m365

#!/bin/bash
ENV_NAME=m365 flow environment list --query '[?contains(displayName,`default`)] .name'
FLOW_NAME=m365 flow list --environment $environmentId --query '[?displayName == `Your sample test flow`] .name'
echo "Exporting your flow"
m365 flow export --environment $ENV_NAME --id $FLOW_NAME -f 'json'

Check out the CLI for Microsoft 365 to learn more at: https://aka.ms/cli-m365

Source Credit

Sample first appeared on Export a single flow to a Logic App | CLI for Microsoft 365

Contributors

Author(s)
Albert-Jan Schot
Luise Freese

Disclaimer

THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

Back to top Script Samples
Generated by DocFX with Material UI