Durable Functions Monitor

repository·main·Indexed 43 days ago

https://github.com/microsoft/durablefunctionsmonitor

A monitoring and debugging UI tool for Azure Durable Functions that allows developers to visualize and manage orchestration instances. It supports multiple backends, including standard .NET runtimes (.NET Core 2.1, 3.1, and .NET 8 Isolated), the Durable Task SQL Provider (MSSQL), and the Netherite Provider. It is available as a set of backends for deployment via ARM templates or Docker, and as a VS Code extension.

Tokens
20.2K
Snippets
68
Records
98
Agent score
52%

What's inside Durable Functions Monitor

  1. Overview of Durable Functions Monitor components

    main

    The repository contains several packages that serve different deployment and integration needs:

    • durablefunctionsmonitor.dotnetbackend: A .NET InProc backend that implements RESTful APIs on top of the Durable Task Framework and serves the React UI statics.
    • durablefunctionsmonitor.dotnetisolated.core: A .NET Isolated backend implementation. This is the package you should "inject" into your own .NET Isolated Function projects.
    • durablefunctionsmonitor.dotnetisolated: A complete .NET Isolated Function project that can be deployed as a standalone Function App instance.
    • durablefunctionsmonitor.react: The client-side React application (TypeScript) that provides the monitoring UI.
    • durablefunctionsmonitor-vscodeext: The implementation for the VS Code extension.
    • custom-backends: Implementations for older framework versions or non-default storage providers like MSSQL or Netherite.
  2. Limitations and custom storage providers

    main

    When using DurableFunctionsMonitor.DotNetIsolated, be aware of the following:

    • Storage Connections: Only the default AzureWebJobsStorage connection string is supported. Multiple storage connection strings are not supported.
    • Non-default Durability Providers: If you use a non-default provider (e.g., MSSQL), you must provide custom routines for retrieving instance history. This is achieved by using the extensionPoints parameter within the .UseDurableFunctionsMonitor() configuration method.
  3. Deploy DurableFunctionsMonitor.DotNetIsolated to Azure

    main

    You can deploy a standalone .NET 7 Isolated version of the DurableFunctionsMonitor backend to your Azure Subscription using the provided ARM template.

    Prerequisites:

    • An existing Azure Active Directory (AAD) application.
    • The Client ID of your AAD application.

    Deployment Steps:

    1. Use the Deploy to Azure button to start the deployment wizard.
    2. When prompted for template parameters, provide the Client Id of your AAD application.
    3. Note that the instance will be deployed to the location of your selected Resource Group. The Region parameter in the Azure Portal wizard only affects deployment metadata and does not control the actual deployment location.

    This deployment installs the backend from the DurableFunctionsMonitor.DotNetIsolated NuGet package.

    https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2FDurableFunctionsMonitor%2Fmain%2Fdurablefunctionsmonitor.dotnetisolated%2Farm-template.json
  4. Run Durable Functions Monitor for Netherite locally

    main

    To run the Netherite storage provider backend locally, follow these steps:

    1. Clone the repository.
    2. Create a local.settings.json file in the project folder with the required connection strings, or set them as environment variables.
    3. Edit the host.json file to specify the taskhub name that matches the application you wish to monitor.
    4. Navigate to the Dfm.Netherite directory in your terminal and run func start.
    5. Access the monitor at http://localhost:7072/ (or the port specified in Properties/launchSettings.json).

    Important Note: The monitored function app must be running for DFM to display information. If the monitored application is unresponsive, DFM will also be unresponsive. This differs from Azure Storage or SQL providers where the storage service can be queried directly.

    {
      "IsEncrypted": false,
      "Values": {
        "DFM_NONCE": "i_sure_know_what_i_am_doing",
        "AzureWebJobsStorage": "insert-azure-storage-connection-string-here",
        "EventHubsConnection": "insert-eventhubs-sas-connection-string-here"
      },
      "Host": {
        "LocalHttpPort": 7072
      }
    }
  5. Install and use Durable Functions Monitor in VS Code

    main

    Durable Functions Monitor is a VS Code extension that allows you to list, monitor, and debug Azure Durable Functions.

    Setup

    1. Install the extension from the VS Code Marketplace or via a VSIX file.
    2. Once installed, a DURABLE FUNCTIONS tab will appear in the AZURE view container.
      • Note: If you do not have the Azure Account extension installed, the tab will appear in the default EXPLORER view container instead.

    Connecting to Task Hubs

    The extension automatically discovers Task Hubs from:

    • Your Azure Subscriptions (if signed in via Azure: Sign In).
    • Your currently opened Azure Functions project.
    • A running Local Storage Emulator.

    To connect to an arbitrary storage account or database (Microsoft SQL Server/Azure SQL), use the Attach to Task Hub... command or click the attach button in the extension view. You will need to provide:

    • A Connection String (Azure Storage or Microsoft SQL Server).
    • A Task Hub name.

    Connection strings are securely stored using the VS Code SecretStorage API.

  6. Override the default DurableFunctionsMonitor endpoint route

    main

    By default, the monitor endpoint is served at http://localhost:7071/my-api-route-prefix/durable-functions-monitor. To serve it from a different route (such as the root), implement a custom class that inherits from ServeStatics and define an Azure Function with an HttpTrigger that calls this.DfmServeStaticsFunction.

    namespace DurableFunctionsMonitor.DotNetIsolated
    {
        public class MyCustomDfMonEndpoint: ServeStatics
        {
            public MyCustomDfMonEndpoint(DfmSettings dfmSettings, DfmExtensionPoints extensionPoints, ILoggerFactory loggerFactory) : 
                base(dfmSettings, extensionPoints, loggerFactory)
            {
            }
    
            [Function(nameof(MyCustomDfMonEndpoint))]
            public Task<HttpResponseData> ServeDfMonStatics(
                [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "/{p1?}/{p2?}/{p3?}")] HttpRequestData req,
                string p1,
                string p2,
                string p3
            )
            {
                return this.DfmServeStaticsFunction(req, p1, p2, p3);
            }
        }
    }
  7. Run the .NET Isolated MSSQL backend locally

    main

    To run the Durable Functions Monitor .NET Isolated backend for MSSQL on your local machine, follow these steps:

    1. Clone the repository.
    2. Create a local.settings.json file in the project folder with the required configuration (see code block).
    3. Open a command prompt in the project folder and run func start.
    4. Access the monitor at http://localhost:7072/durable-functions-monitor.
    {
      "IsEncrypted": false,
      "Values": {
        "AzureWebJobsSecretStorageType": "files",
        "DFM_SQL_CONNECTION_STRING": "your-mssql-connection-string",
        "DFM_NONCE": "i_sure_know_what_i_am_doing",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
      },
      "Host": {
        "LocalHttpPort": 7072
      }
    }
  8. Run Durable Functions Monitor for MSSQL as a Docker container

    main

    You can run the MSSQL backend using a Docker container. You must provide the SQL connection string and a nonce via environment variables.

    Security Warning: Setting DFM_NONCE to i_sure_know_what_i_am_doing disables authentication. Ensure you protect your endpoint appropriately in production environments.

    If your database uses a custom schema, configure it using the AzureFunctionsJobHost__extensions__durableTask__storageProvider__schemaName setting.

    docker pull scaletone/durablefunctionsmonitor.mssql:[put-latest-tag-here]
    docker run -p 7072:80 -e DFM_SQL_CONNECTION_STRING="your-sql-connection-string" -e DFM_NONCE="i_sure_know_what_i_am_doing" scaletone/durablefunctionsmonitor.mssql:[put-latest-tag-here]
  9. Use custom backends for Durable Functions Monitor

    main

    Durable Functions Monitor can be used with custom storage providers by injecting it as a NuGet package into an Azure Function project. This allows you to monitor orchestrations that do not use the default Azure Storage provider.

    Available backend implementations in this repository include:

    • Standard .NET Runtimes:

      • netcore21: Legacy backend for .NET Core 2.1.
      • netcore31: Backend for .NET Core 3.1.
      • dotnetIsolated: Backend for .NET 8 Isolated worker model.
    • Provider-Specific Backends:

  10. Deploy Durable Functions Monitor to Azure (.NET Core 2.1)

    main

    You can deploy a custom Durable Functions Monitor backend configured for .NET Core 2.1 directly to your Azure subscription using the provided ARM template deployment button. This will create a new Function App instance containing these specific backend sources.

    https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fmicrosoft%2FDurableFunctionsMonitor%2Fmain%2Fcustom-backends%2Fnetcore21%2Farm-template.json