When a cloud flow is part of a solution in Power Automate, it gets stored in Microsoft Dataverse as a type of record in the workflow table.
Using either
- Dataverse SDK for .NET: for C# developers, or
- Dataverse Web API: for RESTful access via HTTP,
Use the Dataverse SDK in C#/.NET
Step 1. Create a new .NET console app project. For this project, we are using Visual Studio 2022 and targeting .NET 6.
![New project]()
Step 2. In Solution Explorer, right-click the project you created and select Manage NuGet Packages... in the context menu.
![Manage NuGet package]()
Step 3. Browse for the latest version of Microsoft.PowerPlatform.Dataverse.Client NuGet package and install it.
![Console app]()
Step 4. Add the below code in program.cs file
using Microsoft.Crm.Sdk.Messages;
using Microsoft.PowerPlatform.Dataverse.Client;
using Microsoft.Xrm.Sdk;
class Program
{
// TODO Enter your Dataverse environment's URL and logon info.
static string url = "https://yourorg.crm.dynamics.com"; // Replace your Power Platform Environment Url from https://admin.powerplatform.microsoft.com
static string userName = "[email protected]"; // Power Platform User Login Id
static string password = "yourPassword"; // Power Platform user password
// This service connection string uses the info provided above.
// The AppId and RedirectUri are provided for sample code testing.
static string connectionString = $@"AuthType=OAuth;Url={url};UserName={userName};Password= {password};AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Auto;RequireNewInstance=True";
static void Main()
{
//ServiceClient implements IOrganizationService interface
IOrganizationService service = new ServiceClient(connectionString);
OutputActiveFlows(service);
// Pause the console so it does not close.
Console.WriteLine("Press the <Enter> key to exit.");
Console.ReadLine();
}
public static void OutputActiveFlows(IOrganizationService service)
{
var query = new QueryExpression("workflow")
{
ColumnSet = new ColumnSet("category",
"createdby",
"createdon",
"description",
"ismanaged",
"modifiedby",
"modifiedon",
"name",
"ownerid",
"statecode",
"type",
"workflowid",
"workflowidunique"),
Criteria = new FilterExpression(LogicalOperator.And)
{
Conditions =
{
{ new ConditionExpression("category",ConditionOperator.Equal,5) }, // Cloud Flow
{ new ConditionExpression("statecode",ConditionOperator.Equal,1) } // Active
}
},
//TopCount = 1 // Limit to one record
};
EntityCollection workflows = service.RetrieveMultiple(query);
//Entity workflow = workflows.Entities.FirstOrDefault();
foreach (var workflow in workflows.Entities)
{
Console.WriteLine($"category: {workflow.FormattedValues["category"]}");
Console.WriteLine($"createdby: {workflow.FormattedValues["createdby"]}");
Console.WriteLine($"createdon: {workflow.FormattedValues["createdon"]}");
// Description may be null
Console.WriteLine($"description: {workflow.GetAttributeValue<string>("description")}");
Console.WriteLine($"ismanaged: {workflow.FormattedValues["ismanaged"]}");
Console.WriteLine($"modifiedby: {workflow.FormattedValues["modifiedby"]}");
Console.WriteLine($"modifiedon: {workflow.FormattedValues["modifiedon"]}");
Console.WriteLine($"name: {workflow["name"]}");
Console.WriteLine($"ownerid: {workflow.FormattedValues["ownerid"]}");
Console.WriteLine($"statecode: {workflow.FormattedValues["statecode"]}");
Console.WriteLine($"type: {workflow.FormattedValues["type"]}");
Console.WriteLine($"workflowid: {workflow["workflowid"]}");
Console.WriteLine($"workflowidunique: {workflow["workflowidunique"]}");
}
}
}
Sample Output
category: Modern Flow
createdby: SYSTEM
createdon: 5/20/2020 9:37 PM
description:
ismanaged: Unmanaged
modifiedby: Kiana Anderson
modifiedon: 5/6/2023 3:37 AM
name: When an account is updated -> Create a new record
ownerid: Monica Thomson
statecode: Activated
type: Definition
workflowid: d9e875bf-1c9b-ea11-a811-000d3a122b89
workflowidunique: c17af45c-10a1-43ca-b816-d9cc352718cf
Note. Only flows inside Solutions are accessible this way—not personal flows in the "My Flows" section.
Conclusion
Managing Power Automate cloud flows through code gives developers and IT teams powerful tools to automate, secure, and scale their operations. Whether you prefer the structured approach of the .NET SDK or the flexibility of REST APIs, you can perform critical tasks—like listing, deleting, sharing, and exporting flows—without ever opening the Power Automate UI.
We will see Create, Update, and Delete operations for cloud flows in my next Article.