وبلاگ بلیان

The Complete ASP.NET Core 3 API Tutorial : Hands-On Building, Testing, and Deploying

جلد کتاب The Complete ASP.NET Core 3 API Tutorial : Hands-On Building, Testing, and Deploying

معرفی کتاب «The Complete ASP.NET Core 3 API Tutorial : Hands-On Building, Testing, and Deploying» نوشتهٔ Les Jackson، منتشرشده توسط نشر Apress : Imprint: Apress در سال 2020. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

Use this ASP.NET Core API tutorial and straightforward step-by-step guide to build, test, and deploy an ASP.NET Core API to Azure. It will help you code confidently and efficiently, and provides just what you need for context. The book starts with detailing how to set up your development environment, and then introduces a variety of tools and technologies to build, test, and deploy your API. It covers tools such as .NET Core SDK, (Version 3.1), Visual Studio Code, Git, xUnit, Docker, PostgreSQL, Postman, Azure DevOps, Azure, AutoMapper, and many more. Practical guidance is provided so you can achieve a tangible and valuable outcome, and you also are given a dose of theory on REST (Representational State Transfer), JSON, (JavaScript Object Notation), DTOs (Data Transfer Objects), and the MVC (Model View Controller) architectural pattern. What You Will Learn Build an ASP.NET Core API using C#, test it, and deploy it to Azure Understand concepts on Entity Framework Core Gain hard-earned secrets, shortcuts, and gotchas throughout the "build along" Get comfortable with ASP NET Core Environments Be introduced to unit testing, CI/CD pipelines, bearer authentication, and JSON Web Tokens (JWT) Who This Book Is For Developers using the Microsoft stack. Some basic understanding of .NET Core is assumed. Table of Contents About the Author About the Technical Reviewer Acknowledgments Chapter 1: Introduction Why I Wrote This Book Apress Edition The Approach of This Book Where Can You Get the Code? Main Solution Repository (API and Unit Tests) Secure Daemon Client Repository Conventions Used in This Book Version of the .net Core Framework Contacting the Author Defects and Feature Improvements Chapter 2: Setting Up Your Development Environment Chapter Summary When Done, You Will The Three Amigos: Windows, Mac, and Linux Your Ingredients Links to the Software and Sites Install VS Code C# for Visual Studio Code Insert GUID Install .NET Core SDK Install GIT Name and Email Install Docker [Optional] What Is Docker? Docker Desktop vs. Docker CE Post-installation Check Docker Plugin for VS Code Install PostgreSQL Install DBeaver CE DBeaver vs. pgAdmin Install Postman Trust Local Host Development Certs Wrapping It Up Chapter 3: Overview of Our API Chapter Summary When Done, You Will What Is a REST API? Our API Payloads Five Minutes On JSON Anatomy of a Simple JSON Object A (Slightly) More Complex Example A Final Example Chapter 4: Scaffold Our API Solution Chapter Summary When Done, You Will Solution Overview Scaffold Our Solution Components Creating Solution and Project Associations Anatomy of An ASP.NET Core App The Program and Startup Classes The Program Class The Startup Class ConfigureServices Configure Chapter 5: The “C” in MVC Chapter Summary When Done, You Will Quick Word on My Dev Setup Start Coding! Call the Postman What Is MVC? Model–View–Controller Models, Data Transfer Objects, Repositories, and Data Access What’s the Distinction? Why Decoupling Is Good? Bringing It Together Our Controller 1. Using Directives 2. Inherit from Controller Base 3. Set Up Routing 4. APIController Attribute 5. HttpGet Attribute 6. Our Controller Action Synchronous vs. Asynchronous? Source Control Git and GitHub What’s the difference? Setting Up Your Local Git Repo .gitignore file Track and Commit Your Files Set Up Your GitHub Repo Create a GitHub Repository So What Just Happened? Chapter 6: Our Model and Repository Chapter Summary When Done, You Will Our Model Data Annotations Our Repository What Is an Interface? What About Implementation? Our Mock Repository Implementation Dependency Injection Back to the Start (Up) Applying Dependency Injection Constructor Dependency Injection Update Our Controller Chapter 7: Persisting Our Data Chapter Summary When Done, You Will Architecture Progress Check PostgreSQL Database Using Docker Docker Command Prompt Connecting with DBeaver Connection Issues Entity Framework Core The What and Why of ORMs Entity Framework Command-Line Tools Create Our DB Context Reference Packages Update appsettings.json Create User – SQL Where’s Our Database? Revisit the Startup Class Create and Apply Migrations Code First vs. Database First Adding Some Data Tying It Altogether Create a New Repository Implementation Get All Command Items Get A Single Command (Existing) Get A Single Command (Not Existing) Wrapping Up the Chapter Redact Our Login and Password Chapter 8: Environment Variables and User Secrets Chapter Summary When Done, You Will Environments Our Environment Setup The Development Environment So What? Make the Distinction Order of Precedence It’s Time to Move Let’s Break It Fix It Up User Secrets What Are User Secrets? Setting Up User Secrets Deciding Your Secrets Where Are They? Code It Up Step 1: Remove User ID and Password Step 2: Build Our Connection String Wrap It Up Chapter 9: Data Transfer Objects Chapter Summary When Done, You Will Architecture Review The What and Why of DTOs Decouple Interface from Implementation (Again) Implementing DTOs Create Our DTOs Setting Up AutoMapper Using AutoMapper Chapter 10: Completing Our API Endpoints Chapter Summary When Done, You Will Persisting Changes in EF Core DB Context Tracks Changes The Create Endpoint (POST) Input Object Success Outputs Idempotency Updating the Repository Implement SaveChanges CommandCreateDto Create the New DTO Update the AutoMapper Profile Updating the Controller 1. HttpPost 2. Return DTO Type 3. Input DTO Type 4. Map Our CommandCreateDto to a Command Object 5. Persist Our Data 6. Map Our Created Command Back to a CommandReadDto 7. Created at Route Manually Testing the Create Endpoint Successful Test Case Unsuccessful test Case – Badly Formed JSON Unsuccessful Test Case – Contradict Our Annotations The Update Endpoint #1 (PUT) Input Object Success Outputs Idempotent Updating the Repository Remember How Our DB Context Works CommandUpdateDto Update the AutoMapper Profile Updating the Controller 1. HttpPut 2 Inputs 3. Attempt Command Resource Retrieval 4. Return 404 Not Found 5. Update our Command 6. Update Nothing 7. Save Changes 8. Return 204 No Content Manually Testing the Update (PUT) EndPoint Successful Test Case Unsuccessful Test Case - Contradict Our Annotations Unsuccessful Test Case – Invalid Resource ID The Update Endpoint #2 (PATCH) Input Object Idempotent Updating the Repository CommandUpdateDto Install Dependencies for PATCH Updating the Startup Class Updating the Controller 1. HttpPatch 2. JsonPatchDocument 3. Attempt Command Resource Retrieval 4. Create Placeholder CommandUpdateDto 5. Apply the Patch Document 6. Validate Model Changes 7. Map Updated Dto to Command and Return Manually Testing the Update (PATCH) EndPoint Successful Test Case The Delete Endpoint (DELETE) Updating the Repository CommandDeleteDto Updating the Controller Wrap Up Chapter 11: Unit Testing Our API Chapter Summary When Done, You Will What Is Unit Testing Protection Against Regression Executable Documentation Characteristics of a Good Unit Test What to Test? Unit Testing Frameworks Arrange, Act, and Assert Arrange Act Assert Write Our First Tests Testing Our Model Don’t Repeat Yourself Test Our Controller Revisit Unit Testing Characteristics GetAllCommands Unit Tests and Groundwork GetAllCommands Overview GetAllCommands Unit Tests Groundwork for Controller Tests Mocking Frameworks Install Moq and AutoMapper Using Moq (Mock the Repository) Mock AutoMapper? Finish Test 1.1 – Check 200 OK HTTP Response (Empty DB) Test 1.2 – Check Single Resource Returned Test 1.3 – Check 200 OK HTTP Response Test 1.4 – Check the Correct Object Type Returned GetCommandByID Unit Tests GetCommandByID Overview GetCommandByID Unit Tests Test 2.1 – Check 404 Not Found HTTP Response Test 2.2 – Check 200 OK HTTP Response Test 2.3 – Check the Correct Object Type Returned CreateCommand Unit Tests CreateCommand Overview CreateCommand Unit Tests Test 3.1 Check If the Correct Object Type Is Returned Test 3.2 Check 201 HTTP Response UpdateCommand Unit Tests UpdateCommand Overview UpdateCommand Unit Tests Test 4.1 Check 204 HTTP Response Test 4.2 Check 404 HTTP Response PartialCommandUpdate Unit Tests PartialCommandUpdate Overview PartialCommandUpdate Unit Tests Test 5.1 Check 404 HTTP Response DeleteCommand Unit Tests DeleteCommand Overview DeleteCommand Unit Tests Test 6.1 Check for 204 No Content HTTP Response Test 6.2 Check for 404 Not Found HTTP Response Wrap It Up Chapter 12: The CI/CD Pipeline Chapter Summary When Done, You Will What Is CI/CD? CI/CD or CI/CD? What’s the Difference? So Which Is It? The Pipeline What Is Azure DevOps? Alternatives Technology in Context Create a Build Pipeline What Just Happened? Azure-Pipelines.yml File I Thought We Wanted to Automate? Triggering a Build Revisit azure-pipelines.yml Another VS Code Extension Running Unit Tests Breaking Our Unit Tests Testing – The Great Catch All? Release/Packaging Wrap It Up Chapter 13: Deploying to Azure Chapter Summary When Done, You Will Creating Azure Resources Create Our API App Create Our PostgreSQL Server Azure Database for PostgreSQL Servers Container Instance Pricing Connect and Create Our DB User Revisit Our Dev Environment Setting Up Config in Azure Configure Our Connection String Configure Our DB User Credentials Configure Our Environment Completing Our Pipeline Creating Our Azure DevOps Release Pipeline Pull the Trigger – Continuously Deploy Wait! What About EF Migrations? Double-Check Chapter 14: Securing Our API Chapter Summary When Done, You Will What We’re Building Our Authentication Use Case Overview of Bearer Authentication Bearer Token vs. JWT Build Steps Steps for Our API Project Steps for Our Daemon Client Registering Our API in Azure AD Create a New AD? Switching Between AADs Register Our API Client ID Tenant ID Expose Our API Update Our Manifest Add Configuration Elements Update Our Project Packages Updating our Startup Class Update Configure Services Update Configure Authentication vs. Authorization Update Our Controller Register Our Client App Create a Client Secret Configure API Permissions Create Our Client App Our Client Configuration Add Our Package References Client Configuration Class Finalize Our Program Class Updating for Azure Client Configurations Deploy Our API to Azure Epilogue Index Use this ASP.NET Core API tutorial and straightforward step-by-step guide to build, test, and deploy an ASP.NET Core API to Azure. It will help you code confidently and efficiently, and provides just what you need for context. The book starts with detailing how to set up your development environment, and then introduces a variety of tools and technologies to build, test, and deploy your API. It covers tools such as .NET Core SDK, (Version 3.1), Visual Studio Code, Git, xUnit, Docker, PostgreSQL, Postman, Azure DevOps, Azure, AutoMapper, and many more. Practical guidance is provided so you can achieve a tangible and valuable outcome, and you also are given a dose of theory on REST (Representational State Transfer), JSON, (JavaScript Object Notation), DTOs (Data Transfer Objects), and the MVC (Model View Controller) architectural pattern. What You Will Learn: Build an ASP.NET Core API using C#, test it, and deploy it to Azure Understand concepts on Entity Framework Core Gain hard-earned secrets, shortcuts, and gotchas throughout the "build along" Get comfortable with ASP NET Core Environments Be introduced to unit testing, CI/CD pipelines, bearer authentication, and JSON Web Tokens (JWT) This book is for developers using the Microsoft stack. Some basic understanding of .NET Core is assumed. Les Jackson is originally from Glasgow, Scotland but has lived and worked in Melbourne, Australia since 2009. Since completing his computer science degree in 1998, he has worked in IT, primarily in the telecommunications industry and with the incumbent national telecom providers. Les holds several industry accreditations and has re-acquired a Microsoft Certified Solution Developer certification, although he still believes there is no substitute for experience and passion and says, beware of people touting certifications! Aside from his day job, Les enjoys producing content for his YouTube channel and blog, where he hopes to grow his wonderful audience over the coming years. In his downtime he likes cycling, trying to grow vegetables, making (and drinking) beer, and traveling with his partner. Les Jackson, originally from Glasgow, Scotland, lives and works in Melbourne, Australia. He has been an IT professional since completing his computer science degree. He holds several industry accreditations, including a Microsoft Certified Solution Developer (MCSD) certification, His mantra is that there is no substitute for experience and passion. In his down time, he enjoys producing content for his popular tutorials on YouTube.
دانلود کتاب The Complete ASP.NET Core 3 API Tutorial : Hands-On Building, Testing, and Deploying