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 now! 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
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Developing Solutions for Microsoft Azure AZ-204 Exam Guide

You're reading from   Developing Solutions for Microsoft Azure AZ-204 Exam Guide A comprehensive guide to passing the AZ-204 exam

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781835085295
Length 428 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Paul Ivey Paul Ivey
Author Profile Icon Paul Ivey
Paul Ivey
Alex Ivanov Alex Ivanov
Author Profile Icon Alex Ivanov
Alex Ivanov
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Chapter 1: Azure and Cloud Fundamentals 2. Chapter 2: Implementing Azure App Service Web Apps FREE CHAPTER 3. Chapter 3: Implementing Containerized Solutions 4. Chapter 4: Implementing Azure Functions 5. Chapter 5: Developing Solutions That Use Cosmos DB Storage 6. Chapter 6: Developing Solutions That Use Azure Blob Storage 7. Chapter 7: Implementing User Authentication and Authorization 8. Chapter 8: Implementing Secure Azure Solutions 9. Chapter 9: Integrating Caching and Content Delivery within Solutions 10. Chapter 10: Monitoring and Troubleshooting Solutions by Using Application Insights 11. Chapter 11: Implementing API Management 12. Chapter 12: Developing Event-Based Solutions 13. Chapter 13: Developing Message-Based Solutions 14. Chapter 14: Accessing the Online Practice Resources 15. Other Books You May Enjoy

Exercise 5: Implementing and Observing Application Logging

In the 02-appsettings-logging app you just deployed, some code already existed that creates log entries. In this exercise, you will see this in action in App Service:

  1. From the 02-appsettings-logging folder, open the Pages\Index.cshtml.cs file:
Figure 2.18: The Index.cshtml.cs file within VS Code

Figure 2.18: The Index.cshtml.cs file within VS Code

Within that file, you’ll see the following basic code that simply writes an information log message:

_logger.LogInformation("Hello, Packt! I'm logging for the AZ-204!");
  1. Run the app again locally with the following command, then browse to the app, and you’ll see the log entry in the terminal window:
    dotnet run
Figure 2.19: Terminal output showing information logging from the web app

Figure 2.19: Terminal output showing information logging from the web app

Now that we’ve confirmed this works locally, we’ll head to the Azure portal because it’s the easiest way to show options that are different between Linux and Windows apps.

  1. Within the Azure portal, open App Service and click on the App Service logs blade.
  2. Turn Application logging on by setting the toggle to File System and clicking Save.

    To illustrate the differences between Linux and Windows apps, this is what you’d see if you went to the same location from a Windows app:

Figure 2.20: App Service logging options for a Windows App Service

Figure 2.20: App Service logging options for a Windows App Service

  1. Still within the Azure portal, open the Log stream blade. Then, in another browser tab, navigate to the URL of the App Service. You should see the new application log showing something similar to the following:
    023-06-29T19:44:01.262767018Z info: _02_appsettings_logging.Pages.IndexModel[0]
    2023-06-29T19:44:01.262834918Z       Hello, Packt! I'm logging for the AZ-204!

Now that we have a good understanding of some key concepts of App Service and have run through some detailed topics and enabled logging, we’ll look at a topic that was very briefly touched on in Chapter 1, Azure and Cloud Fundamentals: scaling.

You have been reading a chapter from
Developing Solutions for Microsoft Azure AZ-204 Exam Guide - Second Edition
Published in: May 2024
Publisher: Packt
ISBN-13: 9781835085295
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime