30 April 2024

Troubleshooting App Service

 Troubleshooting App Service

You can achieve in three ways

1. Activity Logs

2. Diagnose and solve problems

3. Application insights

CICD Pipeline

 CICD Pipeline

CI can be considered as the first stage in producing and delivering code, and CD as the second. CI focuses on preparing code for release (build/test), whereas CD involves the actual release of code (release/deploy).


  1. Create a build pipeline
  2. Build, Test, Publish and Publish Artifacts
  3. Azure Release pipeline

Publish Artifacts meaning - 

 Azure Artifacts enable developers to store and manage their packages and control who they want to share it with.

https://www.youtube.com/watch?v=eOQL0nXQlLs
In this Azure DevOps CI/CD Pipelines Tutorial video, we will show you building a CI/CD pipeline in Azure DevOps for ASP.NET Core applications. We will introduce you to Azure DevOps CI/CD Pipeline and show you how to set up a CI/CD pipeline using Azure. If you're working on an ASP.NET Core application, then you know that it's important to have a ...
www.youtube.com

Continuous Delivery - Manual Trigger

Continuous Deployment - Continuous Deployment

HTML Helpers in MVC

 HTML Helpers in MVC

@Html.TextBox
@Html.Password
@Html.TextArea
@Html.CheckBox
@Html.RadioButton
@Html.DropDownList
@Html.ListBox
@Html.Hidden
@Html.Display
@Html.Editor
@Html.ActionLink
@Html.BeginForm
@Html.Label

Example of TextBox() in Razor view
@Html.TextBox("txtEmplpyeeName", "", new { @class = "form-control" })

Html Result

<input class="form-control" id="txtUserName" name="txtEmplpyeeName" type="text" value=""> 

Convert DataTable to List In C#

 Convert DataTable to List In C#

You can achieve in below three ways

Using a Loop.
Using LINQ.
Using a Generic Method.

Using Linq
List<Student> studentList = new List<Student>();
    studentList = (from DataRow dr in dt.Rows
            select new Student()
            {
                StudentId = Convert .ToInt32 (dr["StudentId"]),
                StudentName = dr["StudentName"].ToString(),
                Address = dr["Address"].ToString(),
                MobileNo = dr["MobileNo"].ToString()
            }).ToList();

Eager Loading, Lazy Loading

Eager Loading, Lazy Loading

Eager Loading helps you to load all your needed entities at once; i.e., all your child entities will be loaded at single database call. This can be achieved, using the Include method, which returs the related entities as a part of the query and a large amount of data is loaded at once.

User usr = dbContext.Users.Include(=> a.UserDetails).FirstOrDefault(=> a.UserId == userId);

Lazy Loading
It is the default behavior of an Entity Framework, where a child entity is loaded only when it is accessed for the first time. It simply delays the loading of the related data, until you ask for it.

User usr = dbContext.Users.FirstOrDefault(=> a.UserId == userId);

Kestrel Server in Dotnet

 Kestrel Server in Dotnet

Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the recommended server for ASP.NET Core, and it's configured by default in ASP.NET Core project templates.  

ASP.NET Core project templates use Kestrel by default when not hosted with IIS. In the following template-generated Program.cs, the WebApplication.CreateBuilder method calls UseKestrel internally:

var builder = WebApplication.CreateBuilder(args);

When to use which Service, Singleton, Scoped and Transient

 

When to use which Service, Singleton, Scoped and Transient

Singleton approach => We can use this for logging service, feature flag (to on and off module while deployment), and email service,

Scoped approach => This is a better option when you want to maintain a state within a request,

Transient approach =>  Use this approach for the lightweight service with little or no state.

Scoped Approach in detail
The same instance lives for the entire scope of that request, for example; let's suppose one controller has two parameters, both are the objects of the same "Sample" class, then both the objects will share the same instance across the request,

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...