BUILD A FUNCTION APP CALCULATOR WITH AZURE
Tags: beginners, cloudcomputing, devops, azure
Published: 2023-12-20 00:07:48

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzl61rrk1dzrwaqodr1n.png)

* Click on **Create** to create a new function app


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wslbbvuvx45rs99hmb67.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/caabvcw7d3237xwzkazp.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/di8l5lmxqvxzsezqvul2.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rww9vom31xwf3we37kmc.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/im3bze5f0snze3c2v21r.png)

* Select **Azure functions** and click on **continue**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiol01c3whxmbtlyk1sp.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exfuw3xwcd3v8ysmgl2z.png)

* 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/203whmyqv13cn40vnl2c.png)

* 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yimr5jl5riqvg3i39ih.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whfgs4r5tqcvdaubys56.png)

* 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo2650jaar6j55jwwpmd.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6roqdnm4eioef0jztp6.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7cu5l002fs6ufp70qp2f.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u8gsjcy7ay5cwepoxwq6.png)

* Link your Azure account to it and click on **Publish**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wekl2f3c8sufipdeapwk.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53jang5uv1npcklnkvix.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h541h2gbmns3jycrpu8n.png)

* Click on **Get function URL**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m29xo3sqdn87nkzk8cdv.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eqptkytc3q5wdi09isyf.png)

* 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdlycp4r3mgn1n7d27h5.png)

* And there you go. It works!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iyfc1zf47vwokm4qbqk0.png)