0

I need to access logic app history. My understanding is this needs to be done via the azure management api:

API URL: GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/triggers/{triggerName}/histories/{historyName}?api-version=2016-06-01

What is the best way to do this:

  • Azure resource management SDK? - so far i have not found an example where this can be done with the Azure.ResourceManger SDK, but it feels like it should be in there.

  • HTTP request in .NET.: Again i cannot find examples but i assume this is possible.

Appreciate any expertise and advice.

0

1 Answer 1

0

This is a basic C# implementation of the SDK to retrieve the run history which is developed in VS2022. The authentication is done via the user that is logged into Azure from VS.

Authentication

Read here for other options on authenticating to the subscription ...

https://learn.microsoft.com/en-gb/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet

Be sure to install the following nuget packages ...

  • Azure.Identity
  • Azure.ResourceManager
  • Azure.ResourceManager.Logic

This is the sample program ...

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Logic;
using System;
using System.Threading.Tasks;

namespace AzureManagement
{
    internal class Program
    {
        static void Main(string[] args)
        {
            GetLogicApps().Wait();
        }

        static async Task GetLogicApps()
        {
            // Authenticate and create the ArmClient instance.
            var credential = new DefaultAzureCredential();
            var armClient = new ArmClient(credential);
            var subscription = await armClient.GetDefaultSubscriptionAsync();

            // Get all LogicApps.
            var logicAppsEnumerator = subscription.GetLogicWorkflowsAsync().GetAsyncEnumerator();

            try
            {
                while (await logicAppsEnumerator.MoveNextAsync())
                {
                    // For the current LogicApp, retrieve its run history.
                    var logicApp = logicAppsEnumerator.Current;
                    Console.WriteLine(logicApp.Data.Name);

                    var logicAppRuns = logicApp.GetLogicWorkflowRuns();

                    foreach (var logicAppRun in logicAppRuns)
                    {
                        Console.WriteLine($"... Start DateTime = {logicAppRun.Data.StartOn}, End DateTime = {logicAppRun.Data.EndOn}, Status = {logicAppRun.Data.Status}");
                    }
                }
            }
            finally
            {
                await logicAppsEnumerator.DisposeAsync();
            }

            Console.Read();
        }
    }
}

If you need examples of how to use the SDK then start from here ...

https://github.com/Azure/azure-sdk-for-net/blob/Azure.ResourceManager_1.3.1/sdk/resourcemanager/Azure.ResourceManager

Samples aren't far and wide but there is enough information to be dangerous. Once you authenticate, you just need to have the relevant nuget package installed to access the different types of resources.

Sign up to request clarification or add additional context in comments.

1 Comment

this was useful, thank you. I got to the point of reading the logic app action history, but the output link was blank in all cases. Raised this as a bug on github. Until thats resolved i will just do this using HTTP Requests and the standard API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.