Deploy and Run Your First Azure Function

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

Azure Functions is at the core of Azure’s serverless services and is great at building simple APIs, microservices, backend asynchronous jobs, and contributing to integration workflows. In this lab, we will be walking through a simple, but non-trivial example of an Azure function that solves a common healthcare data integration scenario.

In order to make this lab accessible to the broadest audience, all of the work will be done through the Azure portal, and code will be supplied by copy-paste. Previous coding experience in any language and familiarity with HTML are both helpful but not required.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Provision an Azure Function App Using the Azure Portal

If you have any trouble access the Azure portal, review the housekeeping video.

Using the Azure portal, create an Azure Function App that will host .NET functions on Windows infrastructure. When prompted for a .NET version, use whatever version defaults in the UI. The Function App should be provisioned under the Consumption (Serverless) plan, with a backing storage account. All other defaults can be left as-is.

Note: In the setup wizard for the Azure Function App, the option to enable Application Insights may be disabled in your lab environment. As a result, when working with the function code, you may not see the same output in the logging window as what you see in the lab videos. This will not impact your ability to complete the lab.

Deploy a C# .NET Core Function in the App Based on the HTTP Trigger Template
  1. Within the Function App created in the previous objective, create an Azure Function using the HTTP trigger template. Name the function anything you want or keep the default name.
  2. The function code does not need to be modified, but update the parameter passed to return a simple greeting using the student’s name.
  3. The app tests successfully by returning a simple greeting when run.

Note: In the setup wizard for the Azure Function App, the option to enable Application Insights may be disabled in your lab environment. As a result, when working with the function code, you may not see the same output in the logging window as what you see in the lab videos. This will not impact your ability to complete the lab.

Extend the Project by Adding a NuGet Package Configuration
  1. Navigate to the GitHub project referenced in the Additional Resources section of the lab.
  2. Follow the instructions in the Readme.text file to use the Console feature in the Function App UI to create an empty function.proj file.
  3. Navigate back to the function coding window to check the existence of the function.proj file. (Hint: Check the drop-down where the run.csx file is located.)
  4. Back in the GitHub project, follow the instructions in the helper_function.proj file to populate the empty function.proj file with the proper XML NuGet package that references an HTML parser library.
  5. Save your work.
Extend the Function Code to Scrape a Website and Return a URL
  1. Back in the GitHub project, follow the instructions in the helper_run.csx file to modify the sample code in the function you created near the beginning of the lab.
  2. Save your work.
  3. Scan the code to find and copy the URL assigned to var html, and open it in a browser window. This is the website you need to scraped. View the page and the underlying HTML code to identify the filename that should be scraped (returned) by the function, if the code is running properly.
  4. You do not need to modify the code.
  5. Run the code and ensure that it returns the correct filename that was intended to be scraped from the web page.

Additional Resources

View the lab's GitHub repository to see the README file and code snippets.

Imagine you need to regularly download and process a public dataset of physicians, but the naming convention of the file is not strictly enforced, requiring frequent human intervention to retrieve the most recent file from a link on a website. Further, the posting date of the monthly file is inconsistent, so you need to be able to check for the most current file name so that downstream processes can determine when a refresh is appropriate. The rest of your workflow is already automated; you just need to add a custom application to sort out the file name to fully automate the integration pipeline.

This is one kind of challenge that Azure Functions was designed to address. You will first learn how to provision a Function App, then create and test a canned C# .NET function in that app using an HTTP trigger template. After testing the canned function, you will modify its configuration and C# code to scrape a government website. The goal will be to retrieve the URL of the latest monthly file containing U.S. physicians and their national identifiers. The URL string will be returned for further processing by a data pipeline.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?