Achraf Ben Alaya
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
  • Cloud
  • Motivation
  • General Tips & Fix
  • About
    • Resume
SUBSCRIBE
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
  • Cloud
  • Motivation
  • General Tips & Fix
  • About
    • Resume
No Result
View All Result
Achraf Ben Alaya
No Result
View All Result
ADVERTISEMENT
Home Blog Cloud Azure

Migrate and modernize your applications on Azure – Part 2.0 (Azure Functions)

achraf by achraf
April 3, 2021
in Azure, Blog, Cloud
2 min read
0
Migrate and modernize your applications on Azure
0
SHARES
316
VIEWS
Share on FacebookShare on Twitter

After we have created and published our application to azure , it’s time now to modernize it accelerate and simplify application development with serverless compute using the azure function .

The first azure function that we are going to create will play the role of add-task , so instead of using the API we will use this azure function to do the add task job .

Functions can be written in a variety of languages, and will automatically trigger and scale based on your application needs.

Creating the azure Function

In order to create our azure function ,first we need to clique on the solution in order to add a new project and than from the templates we are going to look for function .

next for the setting of the app we will follow the below table

PS : Make sure you set the Authorization level to Anonymous. If you choose the default level of Function, you’re required to present the function key in requests to access your function endpoint.

Visual Studio creates a project and class that contains boilerplate code for the HTTP trigger function type. The boilerplate code sends an HTTP response that includes a value from the request body or query string. The HttpTrigger attribute specifies that the function is triggered by an HTTP request.

If you follow the video below on the blog we will end up having a function like this :

public  class Function1
 {

     private readonly TaskDbContext _TaskDbContext;
     public Function1(TaskDbContext TaskDbContext)
     {
         _TaskDbContext = TaskDbContext;
     }

     [FunctionName("CreateTodo")]
     public async Task<IActionResult> Run(
         [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
         ILogger log)
     {


         log.LogInformation("Creating a new todo list item");
         var requestBody = await new StreamReader(req.Body).ReadToEndAsync();
         var input = JsonConvert.DeserializeObject<ToDo>(requestBody);
         var todo = new ToDo { Name = input.Name, Priority = input.Priority, URD = System.DateTime.Now.ToString() };
         await _TaskDbContext.todo.AddAsync(todo);
         await _TaskDbContext.SaveChangesAsync();
         return new OkObjectResult(input);
     }
 }

The function will create a task based on the ToDo Model .

To see how to create and publish the function you can find detailed explanation below .

ShareTweet
Previous Post

Migrate and modernize your applications on Azure – Part –1 (Migrate Database)

Next Post

Migrate and modernize your applications on Azure – Part 2.0 (Proxy Function)

Related Posts

Block the default URL assigned to the azure web app using azure application gateway
Azure

Block the default URL assigned to the azure web app using azure application gateway

May 31, 2023
56
Block the default URL assigned to the azure web app
Blog

Block the default URL assigned to the azure web app

May 14, 2023
215
What if we can check the cost of Azure resources in a juts few seconds
Azure

What if we can check the cost of Azure resources in a juts few seconds

May 9, 2023
331
Part 5-A : Using Azure DevOps, Automate Your CI/CD Pipeline and Your Deployments
Azure

Part 5-C : Using Azure DevOps, Automate Your CI/CD Pipeline and Your Deployments

May 2, 2023
216
15 E-books that focus on learning Microsoft Azure Cloud
Azure

15 E-books that focus on learning Microsoft Azure Cloud

April 23, 2023
102
Part 5-A : Using Azure DevOps, Automate Your CI/CD Pipeline and Your Deployments
Cloud

Part 5-B : Using Azure DevOps, Automate Your CI/CD Pipeline and Your Deployments

April 20, 2023
123
Next Post
Migrate and modernize your applications on Azure

Migrate and modernize your applications on Azure – Part 2.0 (Proxy Function)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Terraform

Certifications

Microsoft certified trainer (MCT)

Recommended

Azure Static Web App Service

Azure Static Web App Service

September 27, 2020
638
Create a Linux VM with infrastructure in Azure using Terraform

Create a Linux VM with infrastructure in Azure using Terraform

August 30, 2020
2k
How to make the most of each day

How to make the most of each day

February 2, 2021
179
Configure Azure Web App Logging With .NET 5

Configure Azure Web App Logging With .NET 5

December 11, 2020
1.9k
My 2020 Review

My 2020 Review

December 31, 2020
172
Generating report for SSL Certificates for Websites with PowerShell

Generating report for SSL Certificates for Websites with PowerShell

April 10, 2022
686
Facebook Twitter LinkedIn Youtube
Block the default URL assigned to the azure web app using azure application gateway

Block the default URL assigned to the azure web app using azure application gateway

May 31, 2023
Block the default URL assigned to the azure web app

Block the default URL assigned to the azure web app

May 14, 2023
What if we can check the cost of Azure resources in a juts few seconds

What if we can check the cost of Azure resources in a juts few seconds

May 9, 2023

Categories

  • Apps (1)
  • Azure (46)
  • blazor (2)
  • Blog (70)
  • c# (7)
  • Cloud (45)
  • Dapr (4)
  • docker (3)
  • Games (1)
  • General Tips & Fix (1)
  • Kubernetes Service (AKS) (1)
  • motivation (2)
  • Motivation (3)
  • News (9)
  • Resume (1)
  • sql (4)
  • Terrafrom (1)
  • Tricks, Tips and Fixes (3)
  • xamarin (5)
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
  • Cloud
  • Motivation
  • General Tips & Fix
  • About
    • Resume