az-203 certification path Archives - Learn Smart Coding https://blogs.learnsmartcoding.com/tag/az-203-certification-path/ Everyone can code! Wed, 05 Feb 2020 00:21:25 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 209870635 Enabling Diagnostics Logging in Azure App Service https://blogs.learnsmartcoding.com/2020/02/05/enabling-diagnostics-logging-in-azure-app-service/ https://blogs.learnsmartcoding.com/2020/02/05/enabling-diagnostics-logging-in-azure-app-service/#respond Wed, 05 Feb 2020 00:21:25 +0000 https://karthiktechblog.com/?p=346 Introduction If you are looking at this post “enabling diagnostics logging” then you are already familiar with building and hosting web application with in a azure app service. You may also be looking for options to support your application. I will show how to use diagnostics logs that are available with in azure app service. […]

The post Enabling Diagnostics Logging in Azure App Service appeared first on Learn Smart Coding.

]]>
Introduction

If you are looking at this post “enabling diagnostics logging” then you are already familiar with building and hosting web application with in a azure app service. You may also be looking for options to support your application.

I will show how to use diagnostics logs that are available with in azure app service. I will show the options available to configure diagnostics logs.

Reasons for logging

There are various reasons why we log information. However, we should not log for each and every scenario in our application which then creates too much of information from which an useful information can be taken.
To mitigate this problem, Logging Strategies are in place to clarify what, when and why something should be logged.

Most important logging strategies are listed below.

Auditing

This type of information helps to find who has logged in and who performed a particular action in business context. This acts as tracking mechanism.

Detecting Suspicious Activity

Auditing helps in determining any Suspicious Activity by hackers to break into your system by many login attempts or SQL injection, XSS and etc.

Performance Monitoring

Useful logs created to perform an baseline performance and to see whether application is performing as expected.

Error Notification

Generated error logs are useful in timely notification to the team to inform error occurred and you can act accordingly.

Tracing

To troubleshoot issues that do occur in your application, trace messages can be added to the application logic that helps to create path that user has navigated to reach to your application.

Difference between enabling diagnostics logging and application insights

Diagnostic logs has built-in diagnostics to assist with debugging an App Service web app. It can only track just the app Service instance and allow basic log viewing and downloading.

It does supports trace messages and will not capture AI trace or Exceptions from your application. All the logged data are available in files that needs to be manually analysed. This logging affects web app performance.

Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service. It can trace across all the layers in a web application and has enhanced analytics. Also, application insights has SDK with enhanced custom telemetry. E.g. Exceptions and traces plus Pageviews, Events and Metrics.
App insights can also capture diagnostics trace messages. Compared to diagnostics logs, the impact on your app’s performance is very small.

Read more about application insights

You might feel by now that we can go with application insight instead of leaning diagnostics log. You might be here to learn about diagnostics log as this is part of azure AZ-203 certification skill assessment.

To configure the logging, go to your app service and search with keyword “Monitoring” as shown in the below image. You will see “App Service Log” menu in the left side menu.

Enabling Diagnostics Logging in Azure App Service

Types of Diagnostic Logs

There are four types of diagnostics logging namely

  • Application Logging
  • Web Server Logging
  • Detailed Error Message
  • Failed Request Tracing

Application Logging:

Application logging is the place where the coded trace message can be viewed. Each trace messages give specific log level.

Log Levels

  1. Off
  2. Error
  3. Warning
  4. Info
  5. Verbose
Enabling Diagnostics Logging in Azure App Service

You can see that each log level has been given a level number to it, you can choose this level when configuring the application log to see the highest level of logging.

For example, if you choose Warning when configuring, then the Info and Verbose are ignored.

Application logging in file system

Application Logging (Blob)

You can store the log in Blob. If you wish to choose, then you need to create a container first and then use it.

Application logging in blob storage

Web Server Logging:

This contains the Raw HTTP data, like IIS logs that helps to capture the URI, client IP address, port, browser and much more for troubleshooting.

Quota option is used to configure the space used to store the logs.

Retention period option will delete the logs older than the specified number of days.

web server logging

Detailed Error Message:

With custom error response, you can hide the server error response. For example, when there is an 500 – Internal server error occurs, the use gets to see custom error page that is configured instead of seeing server error page.

Detailed error message logging
Detailed error message that is part of Enabling Diagnostics Logging in Azure App Service

Failed Request Tracing:

This is a detailed error logging that shows almost all the logs that you can trace and find the cause of error.

Failed request logging

Diagnose and Solve Problems

There are different types of App Service Diagnostics available. You can choose one or more from the listed options. Each option is useful in its own way of solving problems.

Diagnose and Solve Problems

Conclusion

In this post, I showed enabling diagnostics logging in app service and showed various options that are available for Azure App Service. The details in this post will help to cover a part of knowledge required to complete Azure AZ-203 certification.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post Enabling Diagnostics Logging in Azure App Service appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2020/02/05/enabling-diagnostics-logging-in-azure-app-service/feed/ 0 346
How to: Create API documentation using OpenAPI & Swagger https://blogs.learnsmartcoding.com/2020/01/10/how-to-create-api-documentation-using-openapi-and-swagger/ https://blogs.learnsmartcoding.com/2020/01/10/how-to-create-api-documentation-using-openapi-and-swagger/#respond Fri, 10 Jan 2020 10:45:36 +0000 https://karthiktechblog.com/?p=301 Introduction In this post, I show how to create API documentation using OpenAPI & Swagger. This post will help to cover a part of knowledge required to complete Azure AZ-203 certification. To start with Azure AZ-203 certification, take a look at my post EXAM AZ-203: DEVELOPING SOLUTIONS FOR MICROSOFT AZURE What is API documentation ? […]

The post How to: Create API documentation using OpenAPI & Swagger appeared first on Learn Smart Coding.

]]>
Introduction

In this post, I show how to create API documentation using OpenAPI & Swagger. This post will help to cover a part of knowledge required to complete Azure AZ-203 certification.

To start with Azure AZ-203 certification, take a look at my post EXAM AZ-203: DEVELOPING SOLUTIONS FOR MICROSOFT AZURE

What is API documentation ?

API documentation is the information that is required to successfully consume and integrate with an API. This can be in the form of technical writing, code samples and examples for better understanding how to consume an API.

API Documentation using OpenAPI & Swagger

When consuming a Web API, understanding its various methods can be challenging for a developer who is new to consume our API.

Swagger, also known as OpenAPI, solves the problem of generating useful documentation and help pages for Web APIs.

In this post, Swashbuckle.AspNetCore is shown with a demo app.

Swashbuckle.AspNetCore is an open source project for generating Swagger documents for ASP.NET Core Web APIs.

Additional Resource For Swagger

Swagger

Background of Demo App

I created an demo App with N-Tier architecture that uses Azure SQL database as back end database. Demo app has a controller called Product which does CURD functionality.

The full demo application is available for free and you may download from my GitHub repository.

To download this demo related code, pick branch code “feature/ImplementCURDFunctionality”

Get Started

In this demo app, I will be using my existing asp.net core API app and add code to start showing API documentation using Swagger’s OpenAPI

Setup and Configure OpenAPI & Swagger

Step 1

Install nuget package Swashbuckle.AspNetCore. and some minimum setup to start showing API documentation automatically.

Step 2

Add Swagger configuration to the ConfigureServices method from the Startup class.

services.AddSwaggerGen(
                options =>
                {
                    var assembly = typeof(Startup).Assembly;
                    var assemblyProduct = assembly.GetCustomAttribute().Product;

                    options.DescribeAllEnumsAsStrings();
                    options.DescribeAllParametersInCamelCase();
                    options.DescribeStringEnumsInCamelCase();

                    var info = new Info
                    {
                        Version = "v1",
                        Title = "KarthikTechBlog:Shopping - V1",
                        TermsOfService = "None",
                        Contact = new Contact()
                        {
                            Name = "Karthik",
                            Email = "karthiktechblog.com@gmail.com",
                            Url = "http://www.karthiktechblog.com"
                        }
                    };

                    options.SwaggerDoc("v1", info);

                    // Set the comments path for the Swagger JSON and UI.
                    var basePath = PlatformServices.Default.Application.ApplicationBasePath;
                    var xmlPath = Path.Combine(basePath, "KarthikTechBlog.xml");
                    options.IncludeXmlComments(xmlPath);

                    options.CustomSchemaIds(x => x.FullName);
            }
            );

Step 3

Next is to add Swagger in the request pipeline.

// Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();

            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
            });

Step 4

Add required attributes to the controller action methods to show in API documentation. Adding ProducesResponseType attribute to the method help determines what is expected from API endpoint.

[HttpGet("")]
[ProducesResponseType(typeof(IReadOnlyList), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ModelStateDictionary), StatusCodes.Status404NotFound)]
public async Task GetProducts()
{
	var products = await ProductService.GetProductsAsync();

	var model = Mapper.Map>(products);
	return new OkObjectResult(model);
}

To read more, visit how to implement create, read, update, and delete functionalities using Entity Framework Core

Create API documentation using OpenAPI & Swagger
Create API documentation using OpenAPI & Swagger

Conclusion

In this post, I showed how to create API documentation using OpenAPI & Swagger. This post is part of learning track for azure AZ-203 certification.

That’s all from this post. If you have any questions or just want to chat with me, feel free to leave a comment below.

The post How to: Create API documentation using OpenAPI & Swagger appeared first on Learn Smart Coding.

]]>
https://blogs.learnsmartcoding.com/2020/01/10/how-to-create-api-documentation-using-openapi-and-swagger/feed/ 0 301