DEV Community

Cover image for 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
joseph4real
joseph4real

Posted on • Updated on

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

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
b. On the basic page adopt the below project details as specified in the following “Function App name- JoeCalculator”,

Image description

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

Image description

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
d. Select "Review + create" to review the app configuration selections. After validation is passed click create deploy the function app.

Image description
e. When deployment is complete, click go to resource.

Image description
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

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

Image description
b. Give your project a name and click next.

Image description
c. Select .NET 6, choose http trigger and click create.

Image description
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
The code was successively built.

Image description

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

Image description

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

Image description

Image description

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

Image description
d. Expand and select your function app and click finish.

Image description

Image description
e. Below capture details show the function app is ready to be published.

Image description

f. See the capture below After successful publishing.

Image description
This is output after successive publishing.

Image description
g. From the azure portal, you can see that the function app has been published/deployed.

Image description

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
b. Paste the URL into browser, give “x” and “y” values as shown in the capture and click enter.

Image description
c. After the*” two equals to sign”, add *(&=x=230&y=890)** and press enter.

Image description
d. The sum of 230 and 890 is 1120, this shows Function App calculation is correct.

Image description

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
b. Select create git repository.

Image description
c. The create a Git repo window will appear, enter your repo name and description, uncheck private, and click create and push.

Image description
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
e. Go to your Github account to confirm if you have successfully created and push your files.

Image description

Image description

Formatting ReadMe

Image description

Image description

Top comments (0)