Manage Microsoft Flow flows using the Office 365 CLI


Using the latest beta of the Office 365 CLI, you can manage Microsoft Flow flows in your organization.

Modern workflows

Over the last few months, Microsoft Flow has been steadily making its entrance to organizations using Office 365. At first, many saw it as an alternative to consumer-focused services such as IFTTT. But nowadays, organizations use Microsoft Flow to build complete workflows supporting their business processes.

Regularly, Microsoft releases new Microsoft Flow connectors and actions, making it a more versatile workflow platform. And what it lacks in connectors to some consumer services, it makes up with easy and powerful connections to various Office 365 services.

Microsoft Flow in your organization

Not surprisingly, more and more organizations every day start using Microsoft Flow. And, while it remains primarily and end-user tool, at some point you will want to be able to manage Flows in your organization. Office 365 CLI offers you a set of commands to manage Microsoft Flow flows in your organizations.

Office 365 CLI

Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Office 365 no matter which operating system or shell you use.

While building solutions for Office 365 expands beyond the Windows operating system, managing many of the platform settings is possible only through PowerShell on Windows. As more and more users work on non-Windows machines, it’s inconvenient for them to have to use a Windows virtual machine to configure their tenants. With the Office 365 CLI you can configure your tenant no matter which operating system you use.

Manage Microsoft Flow flows with the Office 365 CLI

The latest beta of the Office 365 CLI offers you a set of commands to manage Microsoft Flow flows in your organization. At the moment of writing this article, it allows you to list Flow environments and get detailed information about Flows. You can expect, that in the future, using the Office 365 CLI you will be able to export and maybe even import Microsoft Flow flows, which will introduce new automation scenarios.

Getting started

To start, install the latest beta of the Office 365 CLI, using:

npm install --global @pnp/office365-cli@next

Next, start the Office 365 CLI by executing:

o365

This will launch the Office 365 CLI command prompt where you can execute commands to manage Microsoft Flow flows in your tenant.

Information about Microsoft Flow in your tenant is exposed through the Azure Management Service. To get information about Flows in your tenant, start with connecting to the Azure Management Service, by typing:

o365$ azmgmt connect

You will be prompted to open your web browser, navigate to https://aka.ms/devicelogin, and enter the login code presented by the Office 365 CLI.

After completing the authentication, you will be able to retrieve the information about Flows in your tenant.

List Microsoft Flow environment

Microsoft Flow flows are organized in environments. A Microsoft Flow environment allows you to isolate the different Flows and their data and govern their usage.

To list Microsoft Flow environments in your tenant, execute:

o365$ azmgmt flow environment list

displayName: Contoso (default)
name       : Default-d87a7535-dd31-4437-bfe1-95340acd55c5

To get more information about the particular environment, execute:

o365$ azmgmt flow environment get --name Default-d87a7535-dd31-4437-bfe1-95340acd55c5

id        : /providers/Microsoft.ProcessSimple/environments/Default-d87a7535-dd31-4437-bfe1-95340acd55c5
location  : europe
name      : Default-d87a7535-dd31-4437-bfe1-95340acd55c5
properties: {"displayName":"Contoso (default)","createdTime":"2018-03-22T20:20:46.08653Z","createdBy":{"id":"SYSTEM","displayName":"SYSTEM","type":"NotSpecified"},"provisioningState":"Succeeded","creationType":"DefaultTenant","environmentSku":"Default","environmentType":"Production","isDefault":true,"azureRegionHint":"westeurope","runtimeEndpoints":{"microsoft.BusinessAppPlatform":"https://europe.api.bap.microsoft.com","microsoft.CommonDataModel":"https://europe.api.cds.microsoft.com","microsoft.PowerApps":"https://europe.api.powerapps.com","microsoft.Flow":"https://europe.api.flow.microsoft.com"}}
type      : Microsoft.ProcessSimple/environments

List Flows in the given environment

For each environment, you can list its Flows. You can either list Flows you own, or you can list all Flows as admin.

To list your own Flows in the given environment execute:

o365$ azmgmt flow list --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5

name                                  displayName
------------------------------------  ----------------------------------------------------
1c6ee23a-a835-44bc-a4f5-462b658efc13  Send myself a reminder in 10 minutes
3989cb59-ce1a-4a5c-bb78-257c5c39381d  Get a daily digest of the top CNN news
3b30c26a-9cdf-42c0-b90c-780317d74d88  Http -> List Flows as Admin,Response
a173bc19-222e-444f-a00a-29b1972a48c3  Get today's weather forecast for my current location

To list all Flows as admin, add the --asAdmin option:

o365$ azmgmt flow list --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5 --asAdmin

name                                  displayName
------------------------------------  ----------------------------------------------------
1c6ee23a-a835-44bc-a4f5-462b658efc13  Send myself a reminder in 10 minutes
3989cb59-ce1a-4a5c-bb78-257c5c39381d  Get a daily digest of the top CNN news
3b30c26a-9cdf-42c0-b90c-780317d74d88  Http -> List Flows as Admin,Response
a173bc19-222e-444f-a00a-29b1972a48c3  Get today's weather forecast for my current location
ac040895-cea5-4d6c-8ddd-a57b46ecc91e  Get updates from the Flow blog
ad12b615-4c64-42a3-adc3-f9fce2697dcb  Block out my Office 365 calendar for an hour
d3e5a476-92bd-4f4c-87e8-7ca1927770fb  Quickly email a note to yourself
e8bb40f1-2a69-49a2-b3cf-401f55356bb0  Send me a push notification with my current location

Finally, to get detailed information about a particular Microsoft Flow, execute:

o365$ azmgmt flow get --name 1c6ee23a-a835-44bc-a4f5-462b658efc13 --environment Default-d87a7535-dd31-4437-bfe1-95340acd55c5

...

If you want to retrieve information about a Microsoft Flow that you don’t own, don’t forget to use the --asAdmin option.

As mentioned earlier, at the moment of writing this article, the Office 365 CLI allows you to retrieve the information about Microsoft Flow environments and their Flows. In the future you can expect additional commands to for example export and import Flows to your environment.

Summary

More and more organizations start using Microsoft Flow every day to build workflows to support their business processes. While Flow is a primarily end-user tool, at some point you will want to automate their governance. Office 365 CLI offers you a set of commands to support automation scenarios for Microsoft Flow in your organization.

Try it now, by installing the latest beta of the Office 365 CLI using npm install --global @pnp/office365-cli@next. More information and the Office 365 CLI manual are available at https://aka.ms/o365cli.

Others found also helpful: