Tuesday, January 24, 2023

Endpoint Execution filters in Minimal API (.NET 7)

Endpoint Execution filters are new Minimal API in .NET 7 and this feature allows developers to perform validations before the actual API request is executed. The developers can validate the input parameters (from the body/query string or URL template) and validate user authentication information as well. 

These validations will make the system more stable and secure as the input parameters are validated before executing the actual code. 

There are three types of Endpoint Execution filters are available.

  • Before Endpoint Execution Filter
  • After Endpoint Execution Filter
  • Short Circuit Execution Filter
To implement Endpoint execution filters, you need to use the IEndpointFilter interface and implement  
InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next ) with your custom logic code. You can access HTTPContext information by using  EndpointFilterInvocationContext context variable.

Before Endpoint Execution Filter:
As the name suggests, first the input parameters or the user authentication information are validated before executing the actual code. 


After Endpoint Execution Filter:
In this type of filter, the actual code is executed first and then the result of the execution will be used for further processing or transformation. 




Short-Circuit Execution Filter:
In this type of filter, the actual code will not be executed instead, the different logic will be performed and the response sent to the user.


The sample project can be downloaded from Github 

Happy Coding !!





Sunday, January 22, 2023

Getting started with Minimal API - Create your project with dotnet CLI

The below blog post helps you to create a new Minimal API project using Visual Studio 2022 in a step-by-step manner. 

https://www.codingfreaks.net/2023/01/getting-started-with-minimal-api-first.html


You can use very simple dotnet CLI command to create a plain Minimal API project.

Syntax:

                dotnet new web


C:\Users\Murali\Documents\temp>dotnet new web -n HelloWorld


The above command creates a new Minimal API project with the name HelloWorld.

When you open the project in Visual Studio and it appears like the below.



Happy Coding !!

Getting started with Minimal API - The first project


This blog post explains, how to create your first Minimal API project using Visual Studio 2022 with .NET 7.

Step 1: Launch VS 2022 or higher 

Step 2: Choose Asp.net Core Web API



Step 3: Click Next and Enter the Project Name, Location name and Solution Name



 

Step 4: Choose Framework Version as .NET 7 & the minimum requirement is .NET 6.

Authentication Type: None

Configure for HTTPS: Yes. Do check the checkbox.

Enable Docker: No. Don’t Check the checkbox

Below are the important to enable Minimal API.

Use Controllers (uncheck to use Minimal API): No (Don’t check the checkbox)

Enable OpenAPI Support: Yes. Do check the checkbox.

Do not use top-level statements: Yes. Do check the checkbox.

 



Step 5: Once the application is successfully created, it appears like the below.


 

 

Step 6: Press F5, to run the application.

The Swagger UI page has been launched and you can view the Weatherforecast API as below.



Step 7: Click on the /weatherforecast API name, click Try it out, execute and you can see the results as below.

 


Happy Coding !!




New features of Minimal APIs in .NET 7

 Here are new features that are released on .NET 7 for Minimal API.





















Tuesday, January 3, 2023

Create a new row in empty collection in Power Apps

 

Here is a syntax for creating a new row in the existing, empty collection.

Patch (<CollectionName>, defaults(<CollectionName>), {})

Here is an example of creating a new row in the existing, empty collection.

Patch (Users, defaults(Users), {})

Now, the Users collection will have one empty row and this updated User collection can be used to bind Gallery or datatable in Power Apps. 


Happy Coding !




Tuesday, June 7, 2022

Serverless components in Azure





Azure Serverless components are categorized as below.








Compute


                Azure Functions
                Azure App Services
                Azure Kubernetes Services (AKS)

Workflows and Integration
                Azure LogicApps
                Azure API Management
                Azure Event Grid
                Azure Service Bus

DevOps
                Azure DevOps

AI and ML
                Azure Cognitive Services
                Azure Bot Services
                Azure Machine Learning

Database
                Azure Cosmos DB
                Azure SQL Server Serverless

Storage
                Azure Blog Storage

Monitoring
                Azure Monitor

Analytics
                Azure Stream Analytics

Monday, June 6, 2022

What is Azure Functions

 

What is Azure Functions?
                Azure Function is a serverless solution / compute service to execute user code based on an event-triggered without maintaining any infrastructure or provisioning any system to execute the code. Azure Function provides the capability to host & execute the user-defined code without provisioning infrastructure.


What are the Azure Functions Versions?
At the time of writing, the current version of Azure Function is 4.x.

Azure Function Version

Support Level

.net Framework version

4.x

GA

.net 6.0

3.x

GA

.net core 3.1

2.x

GA

.net core 2.1

1.x

GA

.net framework 4.7.2

 

What are the programming languages that are supported by Azure Functions?
Currently, Azure Function supports the following programming languages.

  •        C#
  •        F#
  •        Python
  •        TypeScript
  •        JavaScript (Node JS)
  •         PowerShell
  •         Java

Sunday, June 5, 2022

What is Serverless Computing ?


Serverless Computing

Serverless Computing is a cloud-native development that enables developers to focus on their actual development rather than managing infrastructure like OS, Software, hardware etc. 

With the serverless environment, the cloud provider manages infrastructure to run the code without installing any other applications/software. The developer no need to worry about scaling, infrastructure management and provisioning etc.

 

Serverless Computing from different cloud Providers.


Microsoft :

Azure Functions is a cloud service available on-demand that provides all the continually updated infrastructure and resources needed to run your applications.


Amazon Web Services:

AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.


Google Cloud Platform :  

Run your code in the cloud with no servers or containers to manage.


Oracle
           Oracle Functions
          Oracle Functions is a fully managed, multi-tenant, highly scalable, on-demand, Functions-as-a-Service platform. 

Benefits of Serverless Computing
  • Scalability
  • High Availability
  • Pay only the resources what do you use
  • No need to manage servers / Infrastructure

Happy Learning