Loading....
Lab
Cloud Vendor Microsoft Azure
Proficiency Level Cloud Enthusiast
Tags App ServiceAzure FunctionServerless

Summary

In this lab, you will create an Azure serverless app using Azure Functions. The serverless app will use an HTTP trigger and will be publicly accessible via its URL. When invoked, the app will reply with the phrase: “Hello, [your_name]! I am a serverless app!”, where [your_name] will be replaced with the name you pass as a query string parameter to the app.

Each exercise below builds upon the previous one. You should start each new exercise from the last step of the previous exercise unless it is explicitly written otherwise.

Learning Objectives

After completion of this lab, you will be able to:

  • Create Azure serverless apps
  • Use HTTP to trigger the execution of your serverless app
  • Modify the code of the serverless app to reply with the intended message
  • Stop the serverless app to avoid unwanted charges

Prerequisites

To complete this lab, you will need the following:

  • Reliable internet connection
  • A work, school or personal Microsoft Account used to access Microsoft Azure Management Portal
  • A subscription for Microsoft Azure

Exercise #1: Create an Azure Function App Resource

In this exercise, you will create an Azure Function App Resource. Azure Functions are hosted within the App Service cloud service offered by Microsoft.

Steps

  1. Sign into the Microsoft Azure Management Portal at http://portal.azure.com using your Microsoft Account
  2. Click on in the upper left corner right under the logo
  3. In the search box search for Function App and press Enter
  4. On the next screen, click on the button
  5. On the Basics tab in section, Project Details fill in the following information
    Subscription<select your Microsoft Azure subscription>
    Resource groupCreate new
    Resource group name (the text field in the pop up) → computelab02-rg
  6. On the Basics tab in section, Instance Details fill in the following information
    Function App namecomputelab02-[first_and_last_name]-fun
    Runtime stack.NET Core
    RegionWest US 2
    Where [first_and_last_name] is replaced with your first and last name in lower case and no spaces
  7. Click on the button
  8. On the Hosting tab, leave everything as default
  9. Click on the button
  10. On the Monitoring tab, leave everything as default
  11. Click on the button
  12. On the Tags tab, add the following tags:
    Rolehttp serverless
    Labcomputelab02
    Owner<your name>
    OwnerEmail<your email>
  13. Click on the button
  14. Review the summary and click on the button
  15. Wait until the deployment is completed
  16. Once the deployment is completed, click on in the left-hand menu list
  17. Find the computelab02-rg resource group in the list and click on it
  18.  Milestone step:  At this point, you have learned how to create a serverless app in Microsoft Azure using Azure Function App. Note that although you requested the creation of a single resource, multiple were created. Verify that you have the following resources in your computelab02-rg resource group:
    ASP-computelab02rg-<some_letters_and_numbers> App Service Plan
    computelab02-fun Application Insights
    computelab01-fun App Service
    storageaccountcomput<some_letters_and_numbers> Storage account

Exercise #2: Create an Azure Function

In this exercise, you will create an Azure Function. Azure Function is the serverless service offered by Microsoft.

Steps

  1. Click on the computelab02-fun App Service resource
  2. On the Overview screen, click on the button
  3. On the Azure Functions for .NET – getting started screen, select for the Choose a Development Environment step and click on the button
  4. On the Azure Functions for .NET – getting started screen, select for the Create a Function step and click on the button
  5.  Milestone step:  At this point, you have learned how to create an Azure Function with HTTP trigger in your Azure Function App. You can create multiple functions in the same App, each with different triggers.

Exercise #3: Modify the Function Code and Test the App

In this exercise, you will modify the Function code to reply with “Hello, [your_name]! I am a serverless app!”, where [your_name] will be replaced with the name you pass as a query string parameter to the app and test the app.

Steps

  1. In the code editor field, find the following line (line 19):
    ? (ActionResult)new OkObjectResult($"Hello, {name}")
  2. Change the line to the following:
    ? (ActionResult)new OkObjectResult($"Hello, {name}! I am a serverless app!")
  3. Click on the button on top of the code editor
  4. Once the saving is complete, click on the button on top of the code editor
  5. Copy the URL from the pop-up, and open a new browser window
  6. Paste the URL in the browser’s address field and add the following to the end:
    &name=[your_name]

    where [your_name] is your name. The desired text will appear in the browser window.

  7.  Milestone step:  At this point, you have learned how to modify the code for Azure Function with HTTP trigger and test your changes.

Exercise #4: Stop the Function App

In this exercise, you will stop the Function App to prevent unwanted use and save on cost.

Steps

  1. Click on in the left-hand navigation
  2. Click on the button in the Overview tab to stop the Function App
  3.  Milestone step:  At this point, you have learned how to stop the Function App to prevent unwanted use and save on cost.

 

Last Update: October 4, 2019  

October 1, 2019   306   Toddy Mladenov    Compute    
Total 0 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Back To Top