DEV Community

Cover image for BUILD A FUNCTION APP CALCULATOR WITH AZURE
Fred Chukwuma
Fred Chukwuma

Posted on

BUILD A FUNCTION APP CALCULATOR WITH AZURE

  • Log in to Azure portal and search for Function App. Click to open.

Image description

  • Click on Create to create a new function app

Image description

  • Fill in the details in the next tab and click on Review + Create.

Image description

Image description

  • Once it's done deploying, you should click on Go to resource

Image description

  • Open your Visual studio and click on New to open a new project.

Image description

  • Select Azure functions and click on continue

Image description

  • Select Http trigger, you can leave your runtime on .Net6.0, give your function a name and click on continue.

Image description

  • Your function name automatically comes as your project name in the next tab but you can change it if you want to. You can change the location or leave it on default. If you have version control you can check the version control box and click on create

Image description

  • Once it opens the code, on line 13 and 15 change the public static class and functionName to Sum because we want to deal with addition as a sample.

Image description

  • From line 22 to 30, let's take out everything there.

Image description

  • Copy and paste this code from line 22 int x = int.Parse(req.Query["x"]); int y = int.Parse(req.Query["y"]); int result = x + y;

and on line 26, change the responsemessage to result

Image description

  • Go to your task bar and click on Build the Build solution

Image description

  • Once it's done building, it will show you succeeded

Image description

  • Go to Build again but this time click on Publish to Azure

Image description

  • Link your Azure account to it and click on Publish

Image description

  • Go back to Azure and go to your function app overview and click on Refresh

Image description

  • What we created in visual studio will appear in the functions tab, click it to open.

Image description

  • Click on Get function URL

Image description

  • Copy the URL and open a new windows tab to paste it.

Image description

  • When you paste the URL and add any number to this code in front of the URL to test our Http calculator. &y=10&x=10 this is my own number I am adding

Image description

  • And there you go. It works!

Image description

Top comments (0)