Creating A Function App In Azure, Pushing to GitHub and formatting Readme using VS code.
Published: 2023-07-15 16:54:17

Azure Function is a serverless platform as a service (PaaS) in Azure that runs small, single-task code without requiring new infrastructure to be spurn up. 

To understand it better, I will define what a serverless is , it is a cloud computing execution model in which the cloud provider allocates machine resources on demand taking care of servers on behalf of their customers.

In this guide we need to know some basic definition to provide us with a foundation to understanding what a function app is in azure,  we will be covering the below mentioned objectives

- Creating a Function App in Azure.
- Using Visual studio to create a simple calculator App
- Testing the Calculator App and on our web browser
- Pushing files to GitHub and formatting our ReadMe to be readable.


####Steps to Create A Functional App in Azure.
1. Sign up to Azure or login if you already have an existing account.
2. On the search bar, type "Function App", and select funtion app from the listed services below. Then create.
![functionapp01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chfr2jzghu1896m1n3bx.png)
3. On the window that opens, in the basic task pane select an existing subscription, resource group or create a new one, if no resource group exists.
![functionapp02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6u7tqj4jj5seuih6zjs.png)
4. In the instance details, provide a name for the **function app**
Leave radio button **code** selected as default. in the do you want to deploy code or container?
![functionapp03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxfc1yanhd6tt7hjuctu.png)
5.scroll down ,under Runtime stack click the drop down button and select **.NET** 
6. for operating system, leave window as default.
![functionapp04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kscmwont4r6qkqetpzgr.png)
7. For Hosting **consumption model** is selected.
8. Click the Review+ create button below.
![functionapp05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/giqp5kvzipo39qs7oui4.png)
9. Click create button 
![functionapp06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3oavucd3zlue2iwspod.png)
10. When the deployment is complete click on the open resource button.
![functionapp07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/li7vfyc0s8di99p8nq03.png)

####Steps To Creating A Calculator App Using Visual studio

In the below steps we will be creating a simple calculator using function app in visual studio . You will need to have Visual studio installed in your machine to carry out the exercise.

####Steps
1. Launch Visual studio from your local machine. At the right pane, select create a new project.
![Vs01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6m5iqu0h9yi2hvtg7o50.png)
2. In the search bar type "Azure function", or select from the list below and click on the Next button below.
![Vs02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0zr0jy769d1lej5gr1v8.png)
3. In the window that opens next, give the azure function a Project name. Then click the create button below.
![Vs03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v48n42kr6pptzfvzth77.png)
4. In the window that opens, select HTTP trigger. At the right pane select the storage account dropdown button, select browse 
![Vs04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ijxmna40c8fwf7vy4v2.png)
5. An azure storage account appears, create a new one on the existing subscription and click ok.
![Vs05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ykccxa8rf6aroivb6o96.png)
6. click the create button.
![Vs06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aq3j5gv5nnwl91laqv3f.png)

We can see above that we have successfully created our Function App in visual studio. We will start the process to coding our simple calculator app that is triggered on the browser.

######Coding the Calculator App
To code the calculator app, we follow the below steps
1. In line 15,Function App name change it to "JoeCalcFunctApp".
2. Delete from line 22, to line 30.
![Vs07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x0xw3as24ok8dx1kcutj.png)
3.Enter code as shown below to build a simple calculator app.
![Vs08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dmhn1hlgg5cae9n0buhw.png)
4. At the right pane, Right click on the Calculator function app created and select **Build** from the options.
![Vs09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ezd4ytnwe71mo6l82pb7.png)
5. Our Calculator Function app was built successfully.
![Vs10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcdvcrhpxih8xsidg0sz.png)
**Publishing Our Function App to Azure**

To publishing our calculator app to azure, follow the following steps below.
1. At the right pane, Right click on the Calculator function app created and select publish from the options. 
2. In the Publish target, select Azure and click Next.
![Vs11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vw6lwnify2p9bzi8a8ga.png)
3. In the "Publish specific target" ,select Azure function(windows), and click next.
![Vs12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39qbj8ownz0ne0mxtdy0.png)
4.In the function Instance window, your existing subscription name  will be shown, for group leave as default, then for the function app, click the folder with an arrow in front, in the drop down select your function app created in azure. Finally click the finish button below.
![Vs13](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n86p5ce9kgenou8u4f50.png)
5. The next window that appears its the ready to publish window, if satisfied click the publish button.
![vs14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hppuj1dj4kwi995phdl.png)
6. When the publish button is clicked , the function has been successfully published to azure cloud.
![vs15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4rgo7ji57hwmub7r95j.png)

###Testing Your Function App on The Browser.
Alright its been an amazing journey so far, we are now going to test our calculator app on our browser to ensure its working properly. Follow this steps below to achieve this process.
1. Open the Azure portal and select function app from the home screen.
![webfun01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qivq1sl1jrnam5bnl6ua.png)
2. At the left pane, scroll down to Function and select. We can see the calculator app created.
![webfun02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/etchmm71qm0zr2465bn1.png)
3. Click the App to open it and copy the get function URL.
![webfun03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h2d7g0d49ql54jrs8lql.png)
4. On a browser address bar paste the copied URL.
![webfun04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4otk0auv7881uarttg3j.png)
5.The above window shows "this page is not working". To test our code at the end of the pasted URL, after "==", type **&x=n&y=n**. **Note: n is an integer.**
![webfun05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tthb3wernko0trwhvc6.png)

####Pushing Files To GitHub and formatting Readme

 In the below steps i will guide you on how to push our calculator application to GitHub and format our files in human readable format. 
We are required to have an existing GitHub account to do this successfully.
1. Login into your GitHub account, on the dashboard click on **new**
![readme01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z8i01r0ue8h84cxycg0u.png)
2. In the create repository window , give your file a name and below ,make sure the add a Readme file is selected.
![Readme02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6syahh6rowchxmtdcfbh.png)
3. Click the create repository button below.
![readme03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4h4rw5tlibltt2vsxktu.png)
3. On the azure portal ,select the Calculator function application, on the left pane, scroll down to Deployment, select deployment center.
4. In the **Source**, click the drop-down arrow and select** GitHub** from the options provided, then click the Authorize button.
![readme04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4h7gkxwpb4y7nfcxqlpv.png)
5. In the next window, an authorization window opens, click on the Authorize Azure App services button below.
![readme05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bm3by8bqjz8id8bi1o6.png)
6. Enter your password and click on the confirm button.
![readme06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2c57p2rn3svoyqh7yoku.png)
7. The Function App opens a second time, your GitHub username is shown by default. In the Repository, click the drop-down arrow and select the function app deployed. For Branch, select **Main**  , and click on the save button above.
![readme07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mp48nnu6ag1h7slepnu3.png)
8. Clicking the notification button above it shows that GitHub setting up and deployment was completed.
![readme08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/506z3ycig0088boqxayz.png)
9. On the Function app on GitHub account, open main and click to see our deployed  . 
![readme09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fi3wd4lyneycdlrz88bq.png) 
Alright, we are done with the deployment of our Application from Azure to GitHub, next we proceed to formatting our GitHub to be human readable.