How to create a Function App in Azure, Create and Publish the app Code from VS to Azure and push the app files to GitHub
Published: 2023-07-12 12:52:00

In this blog, I will be showing you how to create a function app in Azure, use Visual Studio to create/write the function app code with https trigger, publish the app code to azure through Visual Studio. Furthermore, I will be pushing the app files to GitHub from Visual Studio and formatting the Readme.

**Contents**
•	**Create Function App in Azure
•	Create Function App Code and Publish to Azure
•	Publish the code to Azure
•	Testing the App by doing some Calculation
•	Pushing Function App Files to GitHub from Visual Studio
•	Formatting Readme**

**Create Function App in Azure**
a.	Search for a function app in the search bar and select function app as seen below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4clux7qp528rrbvc19o.png)
b.	On the basic page adopt the below project details as specified in the following “Function App name- JoeCalculator”, 

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

On the hosting page, Select Window OS and Consumption Plan (serverless hosting where you only pay when app runs), seen below.

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

c.	Choose default settings for Networking, Monitoring, Deployment and Tag. Under Deployment, the GitHub is disable so I will be creating a new GitHub repo from visual studio.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3tqb1zpcmfl2wkh38oqv.png)
d.	Select "Review + create" to review the app configuration selections. After validation is passed click create deploy the function app.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v60ml0f3qb5rukrgir02.png)
e.	When deployment is complete, click go to resource.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7dqfj7uyun4v7wk9x3e.png)
f.	Click function to view your function app, this is where you will create your function app or where your function app will be after creating it. I will not create it here, I will be creating it in visual studio, then push it here.

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

**Create Function App Code and Publish to Azure**
a.	Open visual studio, create a new project, select azure function, and click next.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sl2uafe3lp3cyeq8frej.png)
b.	Give your project a name and click next.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lumwxpsvvey7247gndrw.png)
c.	Select .NET 6, choose http trigger and click create.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qhvai0egwmth5skqdjjp.png)
d.	Edit your code in visual studio environment as shown below. Replace the class “function1” and function attribute with the “Sum”, delete line 22 to 30 and replace with the code shown in yellow and build the code.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p13wgzoejd3w7ytm2yuz.png)
The code was successively built. 

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

**Publish the code to Azure**
a.	Right click **_JoecalculatorFunc_** and click publish, then select Azure, and click next.

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

b.	Select Azure function app (windows) and click next.

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


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

c.	You will need to Login to your Azure account, see the capture below after successfully login in.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcqjprs4ona4gktkds8j.png)
d.	Expand and select your function app and click finish.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w1e78dyfjxyprgpa6xps.png)
e.	Below capture details show the function app is ready to be published.

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

f.	See the capture below After successful publishing.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/po95tnslb0ip88ulzdmc.png)
This is output after successive publishing.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmt71tjurgln0rsl07z3.png)
g.	From the azure portal, you can see that the function app has been published/deployed.

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


**_Testing the App by doing some Calculation_**
a.	Click on the Function App “Sum” and click the “Get Function URL” to copy the App URL.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mx9zf28r2dpy80bbwty9.png)
b.	Paste the URL into browser, give _**“x” and “y”**_ values as shown in the capture and click enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wb5go1ekqb996fgpge9h.png)
c.	After the**_” two equals to sign”_**, add **_(&=x=230&y=890)_** and press enter. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hlx3xhlnu0c553xyo5zi.png)
d.	The sum of **_230 and 890 is 1120_**, this shows Function App calculation is correct.

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


**Pushing Function App Files to GitHub from Visual Studio**
a.	Click on git changes by the right bottom side of the VS screen.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5sy9ln9iheaz90xr9cc.png)
b.	Select create git repository.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mqrp96v3khc7qqegzo30.png)
c.	The create a Git repo window will appear, enter your repo name and description, uncheck private, and click create and push.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sf3tynbp27n190btuf9n.png)
d.	After you have succeeded in pushing, the visual studio right side screen will appear as below. This show a new repository has been created.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0f2n3455s7izrwoi9xs.png)
e.	Go to your Github account to confirm if you have successfully created and push your files.

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

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


**Formatting ReadMe**

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

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