Asp.Net Core and Azure with Raspberry Pi 4
Total Page:16
File Type:pdf, Size:1020Kb
TECHNOLOGY IN ACTION™ Asp.Net Core and Azure with Raspberry Pi 4 .Net Core Applications in Raspbian OS — Sibeesh Venu Asp.Net Core and Azure with Raspberry Pi 4 .Net Core Applications in Raspbian OS Sibeesh Venu Asp.Net Core and Azure with Raspberry Pi 4: .Net Core Applications in Raspbian OS Sibeesh Venu Birkenfeld, Germany ISBN-13 (pbk): 978-1-4842-6442-3 ISBN-13 (electronic): 978-1-4842-6443-0 https://doi.org/10.1007/978-1-4842-6443-0 Copyright © 2020 by Sibeesh Venu 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: Aaron Black Development Editor: James Markham Coordinating Editor: Jessica Vakili Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 NY Plaza, New York, NY 10014. 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]; for reprint, paperback, or audio rights, please e-mail [email protected]. 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/978-1-4842-6442-3. For more detailed information, please visit http://www.apress.com/source-code. Printed on acid-free paper To my mother, Thankamani “When you are looking at your mother, you are looking at the purest love you will ever know.” —Charley Benetto Thank you for picking up this book and giving me the most important and precious thing you can share: your time. Table of Contents About the Author .................................................................................ix About the Technical Reviewer .............................................................xi Acknowledgments .............................................................................xiii Introduction ........................................................................................xv Chapter 1: About Raspberry Pi .............................................................1 About Raspberry Pi ...............................................................................................1 The History of the Raspberry Pi .......................................................................2 About Raspberry Pi 4 .......................................................................................3 Raspberry Pi 4 Accessories .............................................................................5 Introduction to the Operating System .................................................................10 Raspbian ........................................................................................................10 Windows 10 IoT .............................................................................................11 About Windows 10 IoT Core ...........................................................................12 Installing the Raspbian Operating System ....................................................12 Using NOOBS to Install the OS .......................................................................17 Summary ............................................................................................................18 Chapter 2: Configuring Your Raspberry Pi ..........................................19 Enabling SSH ......................................................................................................19 Enabling Wi-Fi Configuration ...............................................................................22 Checking Whether the Pi Is Connected to Wi-Fi ..................................................23 v TABLE OF CONtENtS Connecting the Raspberry Pi via SSH .................................................................23 Summary ............................................................................................................28 Chapter 3: Setting Up the Prerequisites to Develop the Application ...................................................................................29 Developing the Application .................................................................................30 Using WSL ...........................................................................................................31 WSL vs. WSL2 ................................................................................................31 Installing WSL ................................................................................................32 Installing the Linux Distribution ..........................................................................34 Setting Up the Connection to Raspberry Pi .........................................................36 Installing .NET Core on Ubuntu ...........................................................................40 Summary ............................................................................................................42 Chapter 4: Creating and Deploying a .NET Core Application to Raspberry Pi .......................................................................................43 Creating a .NET Core Application ........................................................................43 Installing Visual Studio Code Remote WSL Extension .........................................48 Rewriting the Application ....................................................................................51 Deploying the App to Raspberry Pi ................................................................52 Variables in VSCode ............................................................................................56 Debugging the App from Raspberry Pi ................................................................58 Summary ............................................................................................................60 Chapter 5: Playing with Azure IoT Hub and Our Application ..............63 Using Azure IoT Hub ............................................................................................63 Creating an Azure IoT Hub .............................................................................64 Registering a Device in the IoT Hub ..............................................................74 vi TABLE OF CONtENtS Connecting Raspberry Pi to Azure IoT Hub .........................................................76 Monitoring the Device Data and IoT Hub .............................................................81 Adding Custom Event Message Properties .........................................................85 Summary ............................................................................................................86 Chapter 6: Finally, A Windows Terminal That You Can Customize ......87 Using Windows Terminal .....................................................................................87 Windows Terminal Key Features ...................................................................88 Configuring Windows Terminal ......................................................................89 Windows Terminal Preview Version ....................................................................91 Open Folders in Windows Terminal ...............................................................91 Font Weight Support ......................................................................................91 Support to Open a Profile as a Pane ..............................................................91 Change the Tab Color .....................................................................................92 Rename a Tab ................................................................................................93 Summary ............................................................................................................93