Create First Azure Function

What is Azure function?

It’s a new solution from Microsoft Azure for running the small piece of code or independent functionality that performs a single operation, such as micro services or running as a job which can be triggered or scheduled.

In the below steps, I am showing how to create the first Azure function and how we can call it from different clients.

To create your first Azure function, please follow the following steps.

  1. Login to Azure Portal.
  2. On left side, click on +New -> Web + Mobile -> Function App, as shown below:

    Function

  3. In Function App blade, fill in all the required details, such as App name, Select subscription, select or create new resource group, create or select already created App Service Plan, and finally select or create storage account. Then, click Create, as shown in the image below.

    Function App

  4. After successful completion of step 3, it will take you to the Function app dashboard, as shown in the below image. As you can see, there are no functions, as of now, and given details to start testing it.

    test

  5. There are so many options to start with, as we are creating Webhook + API function using C# language, as shown in the below image. Select the highlighted options and click the Create this function button.

    Create This function
  6. The above action creates a function with name HttpTriggerCSharp1 and shows the details in popup about the function dashboard window. Shown in the below image is the Develop tab where the function code is written and we can customize it as per our requirement.

    Develop

  7. If you click on Next button in the popup window, it takes you to the next tab as an Integrate tab and shows how we can configure the inputs and outputs for the function, as shown in below image.

    Integrate

  8. As shown in the below image, there is Function URL which we can use to call our function from browser or any application or code.

    Integrate

  9. As shown in the below image, we are calling the function from browser and passing the name as query string parameter, as it is returned from function with Hello.

    browser

  10. Below image shows the response of step 9, after hitting enter.

    browser
  11. Below image shows how to call it from Fiddler. Paste the Function URL, as stated in step 8, in composer and add Content-Type : application/json in the header, as highlighted. Add the name as json load in the request body and hit the Execute button. Verify the result.

    result

Here, we saw how easy it is to create the Azure Function in the above steps.

Up Next
    Ebook Download
    View all
    Learn
    View all