C# 8 and .NET Core 3 Projects Using Azure - Second Edition

Book description

Get up to speed with using C# 8 and .NET Core 3.0 features to build real-world .NET Core applications

Key Features

  • Learn the core concepts of web applications, serverless computing, and microservices
  • Create an ASP.NET Core MVC application using controllers, routing, middleware and authentication
  • Build modern applications using cutting-edge services from Microsoft Azure

Book Description

.NET Core is a general-purpose, modular, cross-platform, and opensource implementation of .NET. The latest release of .NET Core 3 comes with improved performance and security features, along with support for desktop applications. .NET Core 3 is not only useful for new developers looking to start learning the framework, but also for legacy developers interested in migrating their apps. Updated with the latest features and enhancements, this updated second edition is a step-by-step, project-based guide.

The book starts with a brief introduction to the key features of C# 8 and .NET Core 3.

You'll learn to work with relational data using Entity Framework Core 3, before understanding how to use ASP.NET Core. As you progress, you'll discover how you can use .NET Core to create cross-platform applications. Later, the book will show you how to upgrade your old WinForms apps to .NET Core 3. The concluding chapters will then help you use SignalR effectively to add real-time functionality to your applications, before demonstrating how to implement MongoDB in your apps. Finally, you'll delve into serverless computing and how to build microservices using Docker and Kubernetes.

By the end of this book, you'll be proficient in developing applications using .NET Core 3.

What you will learn

  • Understand how to incorporate the Entity Framework Core 3 to build ASP.NET Core MVC applications
  • Create a real-time chat application using Azure's SignalR service
  • Gain hands-on experience of working with Cosmos DB
  • Develop an Azure Function and interface it with an Azure Logic App
  • Explore user authentication with Identity Server and OAuth2
  • Understand how to use Azure Cognitive Services to add advanced functionalities with minimal code
  • Get to grips with running a .NET Core application with Kubernetes

Who this book is for

This book is for developers and programmers of all levels who want to build real-world projects and explore the new features of .NET Core 3. Developers working on legacy desktop software who are looking to migrate to .NET Core 3 will also find this book useful. Basic knowledge of .NET Core and C# is assumed.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. C# 8 and .NET Core 3 Projects Using Azure Second Edition
  3. Dedication
  4. About Packt
    1. Why subscribe?
  5. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Ebook Manager and Catalogue App - .NET Core for Desktop
    1. Technical requirements
    2. Creating a new WinForms application
      1. Virtual storage spaces and extension methods
      2. The DocumentEngine class
      3. The ImportBooks form
        1. Populating the TreeView control
        2. Populating the storage space list
        3. Saving a selected book to a storage space
      4. Creating the main eBookManager form
      5. Running the eBookManager application
    3. Upgrading to .NET Core 3
      1. Fixing compilation errors
        1. Resource files
        2. The eBookManager screen
        3. importBooks screen
        4. ProcessStartInfo
      2. Benefits of upgrading to .NET Core
    4. Understanding nullable reference types
    5. Exploring XAML Islands
      1. UWP TreeView
        1. WIndowsXamlHost
        2. ItemTemplate
        3. TreeView Item model and ItemsSource
        4. Removing the existing TreeView
    6. Tree shaking and compiling to a single executable
    7. Summary
  8. Task Bug Logging ASP.NET Core MVC App Using Cosmos DB
    1. Technical requirements
    2. Benefits of using Cosmos DB
      1. Why cloud? It's Microsoft's job to scale – not yours
      2. Why Cosmos? Compatibility with industry-leading APIs and global distribution
    3. Setting up Azure Cosmos DB
      1. Subscription/resource group
      2. Account name
      3. API
      4. Location
      5. Geo-redundancy/multi-region writes
    4. Configuring the Cosmos DB instance
    5. Connecting your ASP.NET Core MVC application to Cosmos DB
      1. Adding the NuGet package
      2. Creating the MongoDbRepository class
    6. Reading and writing data to MongoDB
      1. Creating the interfaces and WorkItemService
      2. Creating the view
      3. Modifying the HomeController
      4. Adding work items
      5. Redirecting to the list of work items
    7. Cleaning up the resources
    8. Summary
  9. ASP.NET Azure SignalR Chat Application
    1. Technical requirements
    2. Introducing SignalR
    3. SignalR project
      1. Configuring Azure SignalR
      2. Creating the project
        1. Setting up the project
        2. Adding the SignalR libraries
        3. Building the server
          1. SignalR Hub subclass
          2. Configuration changes
        4. Creating a client
          1. Included libraries
          2. JavaScript functions
        5. Naming section
          1. Chat input
          2. Archive function
    4. Building and running the project
      1. Running the application
      2. Getting the party started
      3. Archiving the chat
    5. The Azure service
    6. Cleanup
    7. Summary
  10. Web Research Tool with Entity Framework Core
    1. Entity Framework (EF) Core history
    2. Code-First versus Model-First versus Database-First approach
    3. Developing a database design
    4. Setting up the project
    5. Installing the required packages
      1. EF Core SQL Server
      2. EF Core tools
      3. Code generation design
        1. Creating the models
        2. Configuring the services
        3. Creating the database
        4. Seeding the database with test data
        5. Creating the controller
        6. Running the application
    6. Testing the application
      1. Arrange/act/assert
      2. In-memory database
      3. What are we testing?
      4. Speed
    7. Deploying the application
      1. Microsoft Azure App Service
      2. Custom targets
        1. FTP
        2. Web Deploy
        3. Web Deploy Package
      3. Folder
      4. Import profile
    8. Summary
  11. Building a Twitter Automated Campaign Manager Using Azure Logic Apps and Functions
    1. Technical requirements
    2. An overview of workflow engines, logic apps, and Functions
    3. Creating an Excel table
    4. Building logic apps in the Azure portal
    5. Building logic apps in Visual Studio
      1. Azure development workload
      2. The logic apps extension
    6. Creating a resource group
    7. Creating the workflow
      1. Step 1 – Choosing a trigger
      2. Step 2 – Reading the Excel file
      3. New Azure function
        1. Deploying and testing the function
      4. Iterating through the spreadsheet
      5. Sending a tweet
      6. Adding a condition and removing the current row
        1. Passing parameters to a function
        2. Back to our condition
        3. Deleting the row
      7. Publishing the logic app
        1. Failure
    8. Cleaning up the Azure resources
    9. Summary
  12. Stock Checker Using Identity Server and OAuth 2
    1. Technical requirements
      1. Visual Studio Installer – new workloads
    2. Identity and permission
    3. Project overview
    4. Stock checker application API
      1. Setup
      2. Adding the controller and routing
      3. Reading stock levels
      4. Updating stock levels
    5. Permissions
    6. Client application
      1. OnPropertyChanged
      2. Commands and API calls
      3. Helper classes
    7. IdentityServer 4
    8. IdentityServer
      1. Securing the API
      2. Client configuration
        1. Login screen
        2. Calling IdentityServer
        3. Capabilities
      3. Setting up IdentityServer
      4. Calling the API
      5. Grant types
      6. Creating and using a valid key
    9. Authorization
      1. Users and roles
      2. IdentityServer
      3. Client
        1. Logic changes and UI changes
        2. Login and navigation changes
        3. Server calls
        4. How to update the quantity when you can't see it
    10. Summary
    11. Suggested improvements
    12. Further reading
  13. Building a Photo Storage App Using a Windows Service and Azure Storage
    1. Technical requirements
    2. Windows Services and Windows Compatibility Pack
      1. Windows Services
      2. Windows Compatibility Pack
    3. Project overview
    4. Configuring Azure Storage
      1. Hot and cold storage
      2. Storage redundancy
      3. Storage account
    5. Creating our Windows Service
      1. Testing the class
    6. Using the Azure Storage Client
      1. Configuring our Service to Access Azure Storage
      2. Finishing off the Cloud Storage Client
      3. Further configuration
      4. Logging
      5. Only uploading images
      6. Uploading existing images
    7. Installing the Windows Service
      1. Code changes
      2. Installation command
    8. Testing and debugging
      1. Step 1 – check the service is running
      2. Step 2 – check the log file
      3. Step 3 – check the Event Viewer
    9. Summary
  14. A Load-Balanced Order Processing Microservice Using Docker and Azure Kubernetes Service
    1. Technical requirements
      1. JMeter
    2. Microservices
      1. Exploring Docker
      2. Kubernetes and orchestration
    3. Creating our microservice
      1. Queues
      2. Sales order generator
        1. The Service bus helper library
        2. Testing our sales order generator and JMeter
      3. JMeter
      4. Logging
      5. Creating a new microservice
        1. Creating our new Docker Container
        2. Creating the microservice logic
      6. Creating a new Azure SQL database
      7. Entity Framework Core
      8. Creating the sales order
      9. The storage queue
    4. Azure Kubernetes Service
      1. Building a Docker image
      2. Azure Container registry
      3. Azure Container Registry
      4. Azure Kubernetes Service
        1. Kubernetes deployment
    5. Load balancing
    6. Cleanup
    7. Summary
  15. Emotion Detector Mobile App - Using Xamarin Forms and Azure Cognitive Services
    1. Technical requirements
    2. Concepts overview
      1. Machine learning
      2. Cross-platform and mobile development
    3. Project overview
    4. Configuring Azure Cognitive Services
    5. Creating the Xamarin application
      1. Taking a picture
        1. Xamarin plugins
        2. Media plugin
        3. TakePicture()
      2. GetEmotionAnalysis()
      3. DisplayData()
        1. CreateLabel()
        2. GetStrongestEmotion()
      4. Button_Clicked
    6. Testing and running on a physical device
    7. Summary
  16. Eliza for the 21st Century - UWP and the MS Bot Framework
    1. Technical requirements
    2. Creating a chatbot
      1. Bot emulator
      2. Echo Bot – Except for Hello
    3. Introducing LUIS
    4. Integrating LUIS into the Bot Framework
      1. Upgrading the template from .NET Core 2.1 to 3.0
        1. UseMvc
        2. AllowSynchronousIO
      2. Intent/response matrix
      3. Publishing the bot
        1. Creating a Channel Registration
      4. MicrosoftAppId and MicrosoftAppPassword
    5. Creating a UWP application
      1. MainPage
        1. Row definitions
        2. ListView
        3. Message and command binding
      2. Data binding and view models
        1. ObservableCollection
        2. Command binding
        3. DirectLineWrapper
      3. Models
      4. RelayCommandAsync
      5. Channels
        1. Direct Line and Web Chat
      6. Bot client
    6. Summary
  17. WebAssembly
    1. Why WebAssembly
      1. Reason one – statically typed
      2. Reason two – compiled
      3. Reason three – speed
      4. Reason four – languages that you know/same language in the frontend and backend
      5. Reason five – existing code
      6. Reason six – deployment
      7. Reason seven – security
    2. Writing WebAssembly
    3. Understanding Blazor
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: C# 8 and .NET Core 3 Projects Using Azure - Second Edition
  • Author(s): Paul Michaels, Dirk Strauss, Jas Rademeyer
  • Release date: December 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789612080