• 9849-xxx-xxx
  • noreply@example.com
  • Tyagal, Patan, Lalitpur

Exercise 1 – Creating a serverless solution using an Azure Function – Core Azure Solutions

Exercise 1 – Creating a serverless solution using an Azure Function

This section will look at the steps to create a simple Hello World type of serverless solution example that will use a function based on an HTTP trigger. When we pass a value, code will be triggered to execute and return a response.

This could be the basis for a very simple inventory or assets, a lookup solution, or any solution that requires a message to be displayed when there is an HTTP request.

In the following subsections, the process of creating a solution has been segregated into tasks for ease of understanding.

Task – Accessing the Azure portal

  1. Log into the Azure portal: https://portal.azure.com.

Task – Creating a Function App

  1. In the search bar, type function app; click on Function App from the results list.
  2. From the Function App blade, click on the + Create button on the top toolbar.
  3. From the Basics tab, set the Project Details settings as required.
  4. Set the Instance Details settings as follows:
    • Function App name: Enter a name; this must be globally unique.
    • Publish: Leave this set to code.
    • Runtime Stack: Set this to .NET.
    • Version: Set this to 3.1.
    • Region: Set this to the region that’s closest to you.
  1. Leave all other tabs with their default settings.
  2. Click Review + create.
  3. On the Review + create tab, review your settings; you may go back to the previous tabs and make edits if required. Once you have confirmed your settings, click Create.
  4. When the deployment is complete, you will receive a notification stating that the deployment succeeded. Now, click Go to resource from the deployment blade or navigate to the Azure Function App instance.

Task – Creating an HTTP triggered function

  1. On the Function App blade, click the created Function App.
  2. On the left menu, in the Functions section, click Functions.
  3. Click + Add from the top toolbar.
  4. From the Add function pop-up window, click HTTP trigger from the

Figure 5.25 – Add function

14. From the Function blade, click Code + Test from the left menu:

Figure 5.26 – Function blade

15. From the Code + Test blade, you will see some auto-generated sample code; this will return a hello (name) message:

Figure 5.27 – Function app code

Task – Testing the function trigger

  1. Click Get function URL from the top toolbar of the code editor and copy the function URL; the key value should be set to the default.
  2. Open a new browser tab and paste in the copied function URL. The function will run when the page is requested and execute the code; this will prompt/require a name to be returned in the string or body response:

Figure 5.28 – HTTP URL trigger

  1. Append &name=yourname to the end of the URL.
  2. When you hit Enter, your function will run and return the name you entered:

Figure 5.29 – HTTP URL response

In this exercise, we looked at creating a Function App to display a hello (name) message when there is an HTTP request; that is, a URL is called. In the following exercise, we will look at creating a serverless solution using an Azure Logic App.

Leave a Reply

Your email address will not be published. Required fields are marked *