How to Create and Test an HTTP-Triggered Function with Azure Function App
Tags: azure, cloud, dotnet, devops
Published: 2023-04-24 22:53:55

Azure Functions is a cloud-based serverless computing service provided by Microsoft Azure that allows developers to run code without having to manage servers. You only pay for the job you complete with the serverless solution. Because it is event driven, you trigger something, it does something, and you pay for the job it accomplishes.

One of the most common ways to trigger an Azure Function is through HTTP requests. In this blog post, we will look at how to develop and test an Azure Function App with an HTTP-triggered function.

**Step 1: Create an Azure Function App**

To begin sign in to the Azure portal using this [link](https://azure.microsoft.com/en-gb/free/) using your Microsoft account credentials.

To create a Function App, type "_**Function App**_" into the search field. 

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


In the results, select "**_Function App_**" and then press the "**_Create_**" button.

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

On the Function App creation page, fill in the required settings:

- Subscription: Choose the subscription that you want to use for the Function App.

- Resource group: To host the function App, you need to create a resource group. To do so, click "**_Create new_**" next to Resource Group and name it.

- Function app name: Give your Function App a unique name.

- Runtime stack: We will use the.NET programming language and version 6 to publish. After you've filled out the runtime stack and version options, select a region where you want your Function App to be hosted. 

The Windows operating system was chosen as the default base OS for the runtime stack, and the default plan is consumption-based.


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


After you've completed all of the necessary parameters, click the "Review + create" button. 

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


After reviewing the parameters, click the "**_Create_**" button to build the Function App.

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

**Step 2: Create an HTTP-triggered Function**

Once the Function App has been set up, we can create a new function. You may access it by clicking on "**_Go to resources_**"


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

Click on Functions in the left-hand menu and then click create

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

Choose the "**_HTTP trigger_**" template

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

Give the new Function a name and click create

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

**Step 3: Code**

Click on "**_Code + Test_**" to view the code

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

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

This code creates an HTTP trigger that can handle GET and POST requests. The function extracts the "name" parameter from the query string and returns the message "**_Hello, {name}. This HTTP trigger function executed successfully._**"

**Step 4: Test the Function in a web browser**

To test the function in a web browser, navigate to overview. Click on the "Get Function URL" button to get the URL for the function. Copy the URL and open your preferred web browser. Paste the URL into the address bar. Add "_&name=YourName_" to the end of the URL and hit "**_Enter_**". The function should return a message similar to the image below


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

The procedure of creating a Function App on the Azure portal is simple. You can rapidly create a Function App and begin developing serverless applications by following these instructions.