ebook img

Migrating ASP.NET Microservices to ASP.NET Core: By Example PDF

163 Pages·2019·4.857 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Migrating ASP.NET Microservices to ASP.NET Core: By Example

Migrating ASP.NET Microservices to ASP.NET Core By Example — Iris Classon Migrating ASP.NET Microservices to ASP.NET Core By Example Iris Classon Migrating ASP.NET Microservices to ASP.NET Core: By Example Iris Classon 29 Gothenburg, Sweden ISBN-13 (pbk): 978-1-4842-4326-8 ISBN-13 (electronic): 978-1-4842-4327-5 https://doi.org/10.1007/978-1-4842-4327-5 Copyright © 2019 by Iris Classon This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Joan Murray Development Editor: Laura Berendson Coordinating Editor: Jill Balzano Cover image designed by Freepik (www.freepik.com) Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www. apress.com/rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/ 9781484243268. For more detailed information, please visit http://www.apress.com/ source-code. Printed on acid-free paper To the .NET community, my second home and whose never- failing encouragement helped keep my fire burning when I second-guessed myself. Table of Contents About the Author ���������������������������������������������������������������������������������xi About the Technical Reviewer �����������������������������������������������������������xiii Acknowledgments ������������������������������������������������������������������������������xv Introduction ��������������������������������������������������������������������������������������xvii Chapter 1: The SaaS System in Question ����������������������������������������������1 Installation Requirements �������������������������������������������������������������������������������������2 Multitenant Software as a Service (SaaS) ������������������������������������������������������������3 What the System Does ������������������������������������������������������������������������������������������4 Architecture ����������������������������������������������������������������������������������������������������������4 Example System Used in This Book ����������������������������������������������������������������������7 Pipeline ���������������������������������������������������������������������������������������������������������������10 Summary�������������������������������������������������������������������������������������������������������������11 Chapter 2: Should We Migrate? ����������������������������������������������������������13 The Benefits ��������������������������������������������������������������������������������������������������������14 Performance ��������������������������������������������������������������������������������������������������14 Built-In Dependency Injection and Logging ���������������������������������������������������15 Flexible Deployment ��������������������������������������������������������������������������������������16 Modular ���������������������������������������������������������������������������������������������������������17 Open Source and Community Driven �������������������������������������������������������������18 Perfect for Containers �����������������������������������������������������������������������������������19 Cross-Platform ����������������������������������������������������������������������������������������������20 v TTaabbllee ooff CCoonnTTeennTTss The Challenges ���������������������������������������������������������������������������������������������������21 Lack of Resources and Documentation ���������������������������������������������������������21 A Lot to Learn ������������������������������������������������������������������������������������������������22 Versions and Changes �����������������������������������������������������������������������������������23 Summary�������������������������������������������������������������������������������������������������������������26 Chapter 3: Phase 1: Analysis ��������������������������������������������������������������27 Preparing the Projects ����������������������������������������������������������������������������������������31 Retargeting ����������������������������������������������������������������������������������������������������31 Removing Unused Types and Members ���������������������������������������������������������35 Removing Unused References �����������������������������������������������������������������������39 Portability Summary ��������������������������������������������������������������������������������������45 Details Tab �����������������������������������������������������������������������������������������������������49 Summarizing the Work Required for Migrating Konstrukt�BL�Main and Its Dependencies ������������������������������������������������������������������������������������50 Analyzing with ICanHasDot�Net ���������������������������������������������������������������������51 Analyzing the Rest of the Solution �����������������������������������������������������������������52 A Note on the Cost �����������������������������������������������������������������������������������������53 Summary �������������������������������������������������������������������������������������������������������54 Chapter 4: Phase 2: Planning the Architecture ����������������������������������55 Available Resources ��������������������������������������������������������������������������������������������55 What to Migrate ��������������������������������������������������������������������������������������������������56 Migrating Everything �������������������������������������������������������������������������������������56 Gradual Migration and a Mixed System ���������������������������������������������������������57 How to Migrate����������������������������������������������������������������������������������������������������57 Migrate Whole Services ���������������������������������������������������������������������������������58 Break Out Logical Parts to New Services ������������������������������������������������������58 Self-Contained Deployment or Framework Dependent ���������������������������������������59 vi TTaabbllee ooff CCoonnTTeennTTss Architecture and Conventions �����������������������������������������������������������������������������60 Summary�������������������������������������������������������������������������������������������������������������62 Chapter 5: Phase 3: Migration ������������������������������������������������������������63 Full Migration ������������������������������������������������������������������������������������������������������63 Partial Migration ��������������������������������������������������������������������������������������������65 Partial Migration Walkthrough �����������������������������������������������������������������������66 Migrating Contracts ���������������������������������������������������������������������������������������69 Search and Replace ���������������������������������������������������������������������������������������75 Using ReSharper to Remove and Import Namespaces ����������������������������������76 Missing Type: ConfigurationManager ������������������������������������������������������������������81 Rewriting to Avoid Unnecessary Dependencies ��������������������������������������������������82 Missing Type: HttpContext�Current ����������������������������������������������������������������83 Dependency Options: New vs� Old MemoryCache �����������������������������������������86 Replacing Dependencies: Logging ����������������������������������������������������������������88 Migrating Unit Tests ���������������������������������������������������������������������������������������89 Conditional Compilation ��������������������������������������������������������������������������������������94 Konstrukt�Tenancy ����������������������������������������������������������������������������������������������97 Migrating to Entity Framework Core �������������������������������������������������������������������97 Scaffolding a Database Context ��������������������������������������������������������������������99 Migrating from ASP�NET to ASP�NET Core ����������������������������������������������������������102 Service Startup ��������������������������������������������������������������������������������������������102 Summary�����������������������������������������������������������������������������������������������������������121 Chapter 6: Phase 4: Upgrading the Deployment Pipeline �����������������123 Konstrukt Continuous Integration and Deployment Pipeline �����������������������������124 Create Version ���������������������������������������������������������������������������������������������������125 Build and Pack ��������������������������������������������������������������������������������������������������126 vii TTaabbllee ooff CCoonnTTeennTTss Run Unit Tests and Run Integration Tests ����������������������������������������������������������126 Push ������������������������������������������������������������������������������������������������������������������126 Deployment Flow ����������������������������������������������������������������������������������������������126 Pipeline Modifications ���������������������������������������������������������������������������������������128 Two Solutions ����������������������������������������������������������������������������������������������������128 CLI First �������������������������������������������������������������������������������������������������������������128 Creating NuGet Packages ���������������������������������������������������������������������������������129 Running Tests ����������������������������������������������������������������������������������������������������129 Deploying ����������������������������������������������������������������������������������������������������������130 Summary�����������������������������������������������������������������������������������������������������������130 Chapter 7: Maintenance and Resources �������������������������������������������133 Framework Changes �����������������������������������������������������������������������������������������134 Announcements and Roadmaps �����������������������������������������������������������������������135 Documentation ��������������������������������������������������������������������������������������������������137 Align Architecture with New Conventions ���������������������������������������������������������138 �N ET Standard ���������������������������������������������������������������������������������������������������138 Test, Test, and Then Test Some More ����������������������������������������������������������������138 Community Resources and Tools ����������������������������������������������������������������������139 Dotnet Templates �����������������������������������������������������������������������������������������139 Portability Analyzer ��������������������������������������������������������������������������������������139 Windows Compatibility Pack �����������������������������������������������������������������������140 �N ET Core Test Explorer for Visual Studio Code �������������������������������������������140 C# for Visual Studio Code ����������������������������������������������������������������������������140 Crowdsourced Tools and Frameworks���������������������������������������������������������140 Crowdsourced �NET Core Global Tools ���������������������������������������������������������140 viii TTaabbllee ooff CCoonnTTeennTTss Stay Up to Date �������������������������������������������������������������������������������������������������141 Microsoft Blogs��������������������������������������������������������������������������������������������141 Podcast ��������������������������������������������������������������������������������������������������������141 Live StandUps ����������������������������������������������������������������������������������������������141 Twitter ���������������������������������������������������������������������������������������������������������142 Forums ��������������������������������������������������������������������������������������������������������142 Videos (General) ������������������������������������������������������������������������������������������142 Video Training ����������������������������������������������������������������������������������������������142 Summary�����������������������������������������������������������������������������������������������������������143 Index �������������������������������������������������������������������������������������������������145 ix About the Author Iris Classon is a force of nature. Her unique and engaging methods of teaching complex topics have garnered her considerable respect from the developer community and a great deal of media attention – Channel 9, Hanselminutes, Computer Sweden, and Developer Magazine – just to name a few. She is a Microsoft MVP and holds multiple certifications. Currently a freelance developer with her company, In Love With Code LTD, Iris can be found consulting for large enterprises and working on backend systems and operations for startups. She often speaks at conferences such as TechDays and NDC and at user groups. Her passion for teaching code extends to her tweets @IrisClasson, her popular blog, StackOverflow, MSDN, and a myriad of other social media sites. xi

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.