- Lab
- A Cloud Guru
Deploy and Run Your First Azure Function
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.
Path Info
Table of Contents
-
Challenge
Provision an Azure Function App Using the Azure Portal
If you have any trouble accessing the Azure portal, review the housekeeping video.
Using the Azure portal, create an Azure Function App that will host .NET (technically, C# script) functions on Windows infrastructure. When prompted for a .NET version, use version 6 (LTS) In-process (This is the only version that will support the C# script we will use to develop a function in the portal).The Function App should be provisioned under the Consumption (Serverless) plan, with a backing storage account. All other defaults can be left as-is.
Notes:
- 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.
- There have been some relatively minor UI changes since this lab was first published. A full refresh of the lab is actively underway. In the meantime, consult the lab guide if you get stuck at any point where the UI does not precisely match the video.
-
Challenge
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.
-
Challenge
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.
-
Challenge
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 scrape. View the page and the underlying HTML code to identify the filename that should be scraped (returned) by the function, assuming 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
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.