Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

Details in Strangler Fig pattern - Azure Architecture Center | Microsoft Learn

Problem

  • Need to incrementally migrate a legacy system to a new service in the cloud and so, gradually.

  • Run 2 separate systems or versions of an app means that clients have to know where particular features are located.

  • Need to minimize the risk from the migration of app and data.

Solution

  • Create a façade that intercepts requests going to the backend legacy system. The façade routes these requests either to the legacy application or the new services.

...

Strangler In Practice

  • Option A : Using Azure Application Gateway.

    • The facade is a reverse proxy and not cesseraly a forward proxy : we can use Azure Application Gateway or Azure Service Fabric Reverse Proxy.

    • We need to have multiple instances of the same service or multiple versions of the same service if we wish to use Azure Application Gateway (Gateway Routing Pattern)

  • Option B : Creating the strangler Fig in code.

    • The other option would be in the code only : we set up our routes, pointing to 2 different clusters (being our apps - modern and legacy).

      1. Create to code related to the read of the routes

      Code Block
      languagec#
      var builder = WebApplication.CreateBuilder(args);
      builder.Services.AddReverseProxy()
          .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
      var app = builder.Build();
      app.MapReverseProxy();
      app.Run();

Confiuration File (AppSetting)

Code Block
languagejson
{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ReverseProxy": {
    "Routes": {
      "weather": {
        "ClusterId": "legacyapp",
        "Match": {
          "Path": "weatherforecast"
        }
      },
      "rain": {
        "ClusterId": "modernapp",
        "Match": {
          "Path": "rainforecast"
        }
      },
      "catchall": {
        "ClusterId": "modernapp",
        "Match": {
          "Path": "{**catch-all}"
        }
      }
    },
    "Clusters": {
      "legacyapp": {
        "Destinations": {
          "destination1": {
            "Address": "https://localhost:7251/"
          }
        }
      },
      "modernapp": {
        "Destinations": {
          "destination1": {
            "Address": "https://localhost:7139/"
          }
        }
      }
    }
  }
}