Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
C# 8 and .NET Core 3 Projects Using Azure
C# 8 and .NET Core 3 Projects Using Azure

C# 8 and .NET Core 3 Projects Using Azure: Build professional desktop, mobile, and web applications that meet modern software requirements , Second Edition

Arrow left icon
Profile Icon Michaels Profile Icon Strauss Profile Icon Rademeyer
Arrow right icon
€32.99
Paperback Dec 2019 528 pages 2nd Edition
eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Michaels Profile Icon Strauss Profile Icon Rademeyer
Arrow right icon
€32.99
Paperback Dec 2019 528 pages 2nd Edition
eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

C# 8 and .NET Core 3 Projects Using Azure

Task Bug Logging ASP.NET Core MVC App Using Cosmos DB

In this chapter, we will take a look at using Cosmos DB with ASP.NET Core MVC by creating a task/bug logging application. A personal task manager is useful, and logging bugs is especially handy when you can't attend to them immediately.

We will cover the following topics in this chapter:

  • Setting up a Cosmos DB instance on Azure
  • Scaling and replication features of Cosmos DB
  • Creating an ASP.NET Core MVC application and integrating Cosmos DB

Cosmos DB is Microsoft's rebranding of a document database called DocumentDB. In addition to providing the facilities of a NoSQL database, it also provides a globally scalable solution with virtually no effort.

Technical requirements

Benefits of using Cosmos DB

It's probably worth spending some time exploring why you might choose to use Cosmos rather than one of the myriad other database engines. There are two questions here: why cloud, and why Cosmos specifically?

Why cloud? It's Microsoft's job to scale – not yours

Because Cosmos DB is managed by Microsoft, transitioning to it means that there are suddenly some things that you don't need to worry about. For example, have you ever tried to configure SQL Server to fail over, or what about if you're located in the US and your customers are in Australia? Cosmos handles all these scenarios for you on a pay-as-you-go arrangement. Obviously, if you want your data replicated on...

Setting up Azure Cosmos DB

Throughout this book, we will be using Azure as the cloud provider of choice. If you want to follow along and do not currently have an account, then you can create one at https://azure.microsoft.com/. At the time of writing, you can sign up for free and receive £150/$200 of credits for the first month.

Once you've signed up, visit https://portal.azure.com. Here, you can manage your Azure resources and check your balance.

All cloud providers (at least at the time of writing) have a business model whereby you will get billed for your usage. The fact that you can walk away from your machine does not necessarily mean that any processes that you may have been running in the cloud will stop. This is a very different paradigm from the days when your machine being off meant that nothing was running. At the end of each chapter that uses cloud resources...

Configuring the Cosmos DB instance

Now that the resource is created, we can treat this database instance as though it was MongoDB. To start with, we'll need to launch the Data Explorer:

From here, we can select the following option to create a new collection:

As you can see, I've left the default values here. It's worth noting that Fixed (10 GB) is not the recommended value, and, in a production-grade application, you would very likely want to choose Unlimited. If you do so, then you will need to provide a partition key. I've left the throughput as the default 1000 Request Units per second (RU/s): this effectively allows you to pay for the performance that you need; the slower you go, the cheaper it is (and vice-versa)! Once created, you should be able to see your new collection:

The last thing to do is to navigate to the connection strings tab and copy...

Connecting your ASP.NET Core MVC application to Cosmos DB

When talking about using Cosmos DB in your application, one wonders how easy it will be to add this functionality to a new ASP.NET Core MVC application. The process is really easy. To start off, create a new project:

  1. Name the project BugTracker:
  1. Select the option to create an ASP.NET Core Web Application:
  1. On the next screen, select the following options (referenced in the screenshot below):
  1. Select ASP.NET Core 3.0 from the drop-down list.
  2. Select Web Application (Model-View-Controller).
  3. Uncheck the Enable Docker Support option. Finally, click on the OK button.
  4. Click Create and your new ASP.NET Core MVC application will be created.

Enabling Docker support for your application can easily be done at creation time. You can also enable Docker support for existing applications.

We will take a look at Docker and how...

Reading and writing data to MongoDB

In this section, we will have a look at how to read a list of work items from the MongoDB database and how to insert a new work item into the database (I use the term work item to refer to a task or a bug). This can be done by performing the following steps:

  1. In the Models folder, create a new class called WorkItem, as shown in the following screenshot:
  1. Add the following code to the WorkItem class. You will notice that Id is of the ObjectId type. This represents the unique identifier in the MongoDB document that gets created.
You need to ensure that you add the following using statement to your WorkItem class using MongoDB.Bson;.

Take a look at the following code:

public class WorkItem 
{ 
    public ObjectId Id { get; set; } 
    public string Title { get; set; } 
    public string Description { get; set; } 
    public int Severity { get...

Cleaning up the resources

As mentioned earlier, Microsoft makes their money from Azure based on your usage. In order to avoid incurring costs, you should always clean up (that is, delete) resources that you no longer need. If, like me, you named your Cosmos DB instance bugtracker, then you can return to the Cosmos DB blade (you may have previously pinned this to your dashboard; otherwise, you should search for this) and select the instance.

Then simply select Delete Account:

As with many Azure resources, you have to complete a second step to confirm that you really want to delete the resource:

It may take a few seconds to complete, and after that, you're done.

Summary

There is still so much that you can learn when it comes to Cosmos DB and ASP.NET Core MVC. A single chapter is certainly not enough to cover it all. The days where databases sit on powerful, expensive servers that are housed in a rack in the office that only one guy has the keys to are very much numbered. This can be seen as good and bad: no-one can accidentally unplug or reboot the server, nor will a local power outage have any effect on it; however, you (or your employer) now pay for inefficient queries in pounds and pence (or dollars and cents).

In the next chapter, we will take a look at SignalR on Azure and how to create a real-time chat application.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 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

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.

Who is this book 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.

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
Estimated delivery fee Deliver to Greece

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 31, 2019
Length: 528 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789612080
Vendor :
Microsoft
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Greece

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Dec 31, 2019
Length: 528 pages
Edition : 2nd
Language : English
ISBN-13 : 9781789612080
Vendor :
Microsoft
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 135.97
Hands-On Parallel Programming with C# 8 and .NET Core 3
€36.99
C# 8 and .NET Core 3 Projects Using Azure
€32.99
C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development
€65.99
Total 135.97 Stars icon
Banner background image

Table of Contents

12 Chapters
Ebook Manager and Catalogue App - .NET Core for Desktop Chevron down icon Chevron up icon
Task Bug Logging ASP.NET Core MVC App Using Cosmos DB Chevron down icon Chevron up icon
ASP.NET Azure SignalR Chat Application Chevron down icon Chevron up icon
Web Research Tool with Entity Framework Core Chevron down icon Chevron up icon
Building a Twitter Automated Campaign Manager Using Azure Logic Apps and Functions Chevron down icon Chevron up icon
Stock Checker Using Identity Server and OAuth 2 Chevron down icon Chevron up icon
Building a Photo Storage App Using a Windows Service and Azure Storage Chevron down icon Chevron up icon
A Load-Balanced Order Processing Microservice Using Docker and Azure Kubernetes Service Chevron down icon Chevron up icon
Emotion Detector Mobile App - Using Xamarin Forms and Azure Cognitive Services Chevron down icon Chevron up icon
Eliza for the 21st Century - UWP and the MS Bot Framework Chevron down icon Chevron up icon
WebAssembly Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela