.NET on AWS Blog

Scaling AWS Toolkit for .NET Refactoring to help modernize large-scale enterprise applications

Introduction

Enterprises are looking to modernize their legacy .NET applications to take full advantage of the cloud. However, modernization is a complex process, typically involving refactoring a monolithic architecture, finding cross-platform replacements for Windows-specific dependencies, and updating application configurations to run in a container or serverless environment. The complexities of large enterprise-grade legacy applications make it challenging for developers to fully understand the composition and determine a starting point.

AWS recently released new updates to the AWS Toolkit for .NET Refactoring extension to enable upgrading large, enterprise-scale legacy applications from within Visual Studio IDE. The AWS Toolkit for .NET Refactoring now provides improved performance for assessing large, multi-project .NET applications and graphical visualization of the application dependencies within Visual Studio. In this post, we’ll walk through how to use the toolkit with a large application.

Large Enterprise Application Support

With the recent set of releases, the toolkit has made significant leaps in performance and the scale of .NET enterprise applications that can be assessed and ported. The motivation comes from the .NET applications we are targeting for modernization. These are large enterprise applications developed over years with tens and thousands of files, classes and methods. A big part of customer workflow before doing the porting is to perform the portability assessment. This step determines how many of the .NET SDK and NuGet Packages in the application are compatible with cross-platform .NET, including the recommended replacements for those. For large applications, performing the entire assessment on the client machine is largely dependent on the client environment and its hardware configuration. We wanted to avoid this dependency and drive towards providing customers a consistent experience and performing assessment at scale.

To accomplish this, we moved towards a hybrid model where some of the heavier computations of assessment are offloaded to AWS through a new backend service. We use the client to compute metadata of the source code that has only the minimal data required to perform portability assessment. The source code never leaves the local system. The metadata is stored in customer owned AWS S3 bucket and our backend service picks it up to perform portability assessment ephemerally using elastic AWS compute and puts the results right back into the same customer owned S3 bucket. The client-side tool then processes it and displays the assessment report to the customer. This model of initial processing on the client-side and performing the heavier computations in the cloud helped us unlock high-performant assessments for large enterprise .NET applications, while also honoring sovereignty and residency requirements for source code to stay within customer’s premise. It is worth noting that the computational cost of the backend AWS service is entirely absorbed by AWS, resulting in faster assessments at no extra cost for customers.

Before we dive into how this model works, let’s briefly introduce the backend service that performs the heavier parts of our assessments. This year, we developed the toolkit to drive the transformation of large-scale enterprise .NET applications including grouping assessment to break down large monolithic .NET applications to microservices, portability assessment from .NET framework to .NET and deploying ported .NET applications to container-based ecosystems in AWS. This service also unlocked the scaling potential for our sister product – AWS Microservice Extractor for .NET, by enabling grouping assessment for .NET applications with very large number of classes and projects. The same service also powers the test deployment of ported application which is a critical part of the toolkit’s post-porting workflow discussed below.

Coming back to the hybrid model, we need both the client-side tool and the AWS service to perform at an optimum level in order to meet the performance expectations of our customers. On the client-side, we made optimizations on how fast we can compute metadata from the onboarded .NET solution/project. We made use of technologies that are native to Visual Studio to boost this by up to 40%. Following this, with the compatibility assessment offloaded to the backend service, we further improved the performance of the toolkit, especially when dealing with large, interdependent solution files. This is huge for customers who do not have to wait long-hours to complete the portability assessment of their large .NET framework applications.

Walkthrough

Now, let’s walk through how you can leverage these new features through the toolkit.

Prerequisites:

  1. Clone Orchard CMS application from GitHub.
  2. Make sure the Orchard CMS solution builds successfully.
  3. A new IAM user with programmatic access and necessary managed policies.
  4. Install AWS Toolkit for .NET Refactoring from Visual Studio extensions.

After installing AWS Toolkit for .NET Refactoring, open Orchard CMS solution in Visual Studio 2022. In the Extensions menu, select the AWS Toolkit for .NET Refactoring extension, then select Get Started.

A few new options are added to the startup configuration for a simplified onboarding. Now, you can set up your S3 bucket to store your deployment artifacts and can use your KMS key to encrypt your data. Also, to test deploy your applications in the Toolkit, you can set up the prerequisites with your IAM roles and credentials.

Figure 1: Setting up prerequisites

Figure 1: Setting up prerequisites

You have an option to set up the prerequisites automatically or manually.

Figure 2: Running setup

Figure 2: Running setup

Now, you can use Toolkit for .NET Refactoring managed policies to test your application on AWS to modernize your application. This policy grants permissions to upload application artifacts and downloading resulting artifacts from S3.

Add the AWS profile with the IAM User you set up earlier (Prerequisites step 3) to get started.

Figure 3: Adding the AWS profile

Figure 3: Adding the AWS profile

The application is ready to be assessed now. Choose Start Assessment. AWS Toolkit for .NET Refactoring assesses the application for compatibility with your target .NET version (Core 3.1, 5, 6, 7, 8), and displays a report covering NuGet packages and APIs.

Figure 4: Starting assessment

Figure 4: Starting assessment

When the assessment is complete, you can view the results in the dashboard.

Figure 5: Assessment results

Figure 5: Assessment results

Select View Project Dependency Graph to view the dependencies of projects in a visual representation. This view will provide you some insights into making important decisions while modernizing your application. If transitioning from a monolith to microservices, consider breaking down functionality into individual components and referencing them in your project as API calls instead of entire project.

Figure 6: Dependency graph view

Figure 6: Dependency graph view

The assessment report contains information on the incompatible NuGet packages, incompatible .NET framework APIs, number of ported projects, APIs and version details of the dependencies that are incompatible with the .NET version selected for the assessment. You can also sort the packages based on the referenced number of projects, APIs, status etc.

Under NuGet packages, you can see the version of the package that is incompatible with the target .NET version and a suggested replacement if any. For example, MySql.Data(6.7.9) package in the report below is incompatible and suggested to use version 6.10.4 for target compatibility.

Figure 7: NuGet packages compatibility report

Figure 7: NuGet packages compatibility report

Under APIs, one of the functionalities for Autofac is incompatible with the target version and the report suggested to upgrade the Autofac to version 4.0.0.

Figure 8: APIs compatibility report

Figure 8: APIs compatibility report

Figure 9: Toolkit compatibility messages in Error List window

Figure 9: Toolkit compatibility messages in Error List window

Once the application is ported, it is time for customers to test it in AWS’s container ecosystem. This validates the Linux-readiness of the ported application to .NET core, as well as its ability to run in modern AWS compute ecosystems such as ECS. The toolkit makes this test deployment stack available with a click of a button. On the dashboard, select Run test deployment to deploy your .NET application into a Linux container running on Amazon Elastic Container Service (Amazon ECS) with AWS Fargate, the serverless compute engine for containers. AWS Toolkit for .NET Refactoring generates all of the required artifacts to containerize your application and run it on Amazon ECS. For more information on setting the test deployment step by step, read the Accelerate .NET modernization with AWS Toolkit for .NET Refactoring blog post. By taking care of setting up the application in AWS, .NET developers can focus on testing their ported application, finalize the code changes and get it ready for production. Furthermore, the deployment stack created by the toolkit is highly optimized for iteratively testing the application. This is achieved by its ability to quickly update the running .NET core application inside the container, following any code changes that customer makes on the Visual Studio IDE. This helps them reduce the testing window for their ported application. In prior versions of the toolkit, you may have seen intermediate artifacts such as AWS CodeBuild projects that were used to create the container in AWS. With the new release, the building of containers happens entirely behind the backend service. This helps abstracting away those intermediate artifacts and saving customers cost by not creating them on customer’s account. The output artifacts continue to be the application endpoint URL for testing and the test deployment CloudFormation stack created in the customer account. Finally, the backend service that orchestrates this deployment is available in all commercial regions, enabling customers to test their application in a region that makes the most geographical sense.

Conclusion

AWS Toolkit for .NET Refactoring extension is available today for Visual Studio 2022. It helps developers transform their enterprise-scale legacy applications from within Visual Studio IDE by porting your .NET Framework application to modern .NET (formerly named .NET core) and automates creating and deploying a test environment based on AWS container services. The new and improved version provides significant performance boost for assessing large, multi-project .NET applications and graphical visualization of the application dependencies within Visual Studio.

Now, you can modernize your legacy .NET applications to .NET 8 using AWS Toolkit for .NET Refactoring. For more information on .NET modernization use cases and tools, see Modernize .NET Workloads on AWS at the .NET on AWS developer center.