Creating A Function On Azure Portal

In this article, we are going to learn how to create a Function in the Azure portal based on the built-in templates available in the portal.


Creating a function on the Azure portal is very easy. In this article, we will learn the process. Then, we will test the functions in the portal and examine the logs.

Step 1

Log in here by using your Azure credentials. I have already got the Azure subscription. If you do not have an Azure subscription, then create a free trial once. The subscription governs the billing for my usage of Azure. 

Step 2

Click on the "Create a resource" button and the search for the "Function App" in the market place. In the search result, select the Function App and click on the "Create" button.
Creating A Function In Azure Portal 

Step 3

In Function App blade, we need to enter a few required fields in order to create the Function app.
  1. Function name - enter the unique name for the function app.

  2. Subscription - If you have multiple subscriptions, then make sure you have selected the appropriate one to create your function app.

  3. Resource group - I would recommend creating the new one because in future if you want to delete your function app, it’s easy to delete all other associated resources also. 

  4. OS - It offers three types, - Windows, Linux, and Docker container. In this demo, I am going to choose Windows because it allows using Consumption Plan at a very minimal cost.

  5. Location - Ideally, it should be nearest/same to the app server’s location in order to increase the system performance.

  6. Application Insights - It’s a very powerful tool for logging and telemetry platform that will give lots of operation insights during the runtime. Application insights may not be available in many locations so, we need to pick the one which is very close to our function app’s location and click on the "Create" button.

Creating A Function In Azure Portal

Step 4
Just take a look at the resource group that is created. There are four things here along with the function app -  storage account and application insights are created. Then, click on the function app service link to create the new function for the same.
Creating A Function In Azure Portal
Creating A Function In Azure Portal

Step 5

Platform feature window allows creating lots of settings for the function app. In Application Setting, we can select the connection string; while deployment settings are used for setting up the Continuous Integration. Create a function and give it a name and select the template which is available in the portal. For this demo, I am selecting the HTTP trigger. Enter a unique name for the function, select the authorization level, and click on the "Create" button.
Creating A Function In Azure Portal

The portal will show you C# runtime editor for writing your own business logic into it. As you see, it's a static asynchronous method, it takes the HTTP request object and returns the HTTP response object. In the query, it will look for the name property. If that is not available, then it will throw an error message - “Please pass a name on the query string or in the request body”. Else, it appends the "Hello" text with the name object and returns to it.

string name = req.Query["name"];

Creating A Function In Azure Portal

Step 6

For testing the function created in the Azure portal, click on the "Get Function URL" button. It generates the URL of the function which we are going to access from outside. In URL, by default, the API key is appended. Remember, when we create the function, we have chosen the authentication mode as function-level, so a secret API key is required if we want to consume a function. Now, we are going to test the function portal itself. Click the "Test" button which is there in the middle of the right side of the same page. Pass the name object and scroll down to the bottom. There, you will get a "Save and Run" button. Click on it to see the output of the function app.

Click the "Monitor" button in order to see the invocation history about the function app.


In this demo, we have learned how to create Functions on the Azure portal and run and test them.