Azure Virtual File System
May 2019 – Jun 2019 · PRMconnect
- .NET
- System.IO
- Azure Storage
- CDN
An injectable drop-in replacement for System.IO that let a legacy codebase move to mixed cloud storage with less than 1% manual edits.
Challenge
As part of the analysis for an Azure refactor project, the target application was found to contain direct dependencies on the local file system. The move strategy dictated that, once in the cloud, assets would be stored in a variety of locations, including local, blob and CDN.
Analysis
- Found several thousand direct references to the physical file system, through static System.IO calls and third-party packages
- Nearly all of those references were outside unit test coverage, so remediating the affected code directly risked creating many new, hard-to-find bugs
Approach
- Created a virtual file system as an injectable direct replacement for System.IO in affected classes
- Designed a path routing scheme so that legacy file naming based on drive letter paths would route to the correct asset locations, with storage-agnostic copy and stream operations between locations
- Extended the routing scheme to provide URL resolution across asset locations, covering Server.MapPath and other assumptions about how physical paths related to URLs
- Added extensive unit test coverage to the new components to catch any bugs before release
Results
- Legacy code was updated by bulk search and replace, with less than 1% manual edits
- Minor issues were all detected in unit or integration testing, with no impact on production
- Production cutover was completed without updating path-related database values or visible path nomenclature