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
- 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.
- The function code does not need to be modified, but update the parameter passed to return a simple greeting using the student’s name.
- 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
- Navigate to the GitHub project referenced in the Additional Resources section of the lab.
- Follow the instructions in the
Readme.text
file to use the Console feature in the Function App UI to create an emptyfunction.proj
file. - Navigate back to the function coding window to check the existence of the
function.proj
file. (Hint: Check the drop-down where therun.csx
file is located.) - Back in the GitHub project, follow the instructions in the
helper_function.proj
file to populate the emptyfunction.proj
file with the proper XML NuGet package that references an HTML parser library. - Save your work.
- Extend the Function Code to Scrape a Website and Return a URL
- 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. - Save your work.
- 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. - You do not need to modify the code.
- Run the code and ensure that it returns the correct filename that was intended to be scraped from the web page.
- Back in the GitHub project, follow the instructions in the