- Lab
- A Cloud Guru
Using Azure Functions with C#
In this lab, you will gain experience using C#, Visual Studio, and Azure Functions. You will build an Azure function using C# code that is triggered by a webhook and saves data to Azure Table storage using a Table storage binding. You will then run a console application to see everything working and will verify that table data was saved using Azure Storage Explorer. Finally, you will check the Azure portal to ensure telemetry data was saved to Application Insights. Upon completion of the lab, you will have gained the experience required to work with Azure Functions using C#.
Path Info
Table of Contents
-
Challenge
Create Function and Application Insights in the Azure Portal
- Review the lab-provisioned resources.
- Take note of the resource group location and the 5 character suffix for all of the deployed resources. These will be used later in the lab.
- Create a new function app.
- Once deployed, enable Application Insights.
-
Challenge
RDP into the VM, Configure Storage Explorer, and Open the Visual Studio Solution
- Download the RDP file for the lab-provided VM.
- Connect to the VM, clone the Azure labs repository, and extract from it the solution file for the lab.
- Download and install Azure Storage Explorer.
- Configure storage explorer using resources created in the lab.
- Open the extracted solution file to start Visual Studio.
-
Challenge
Update and Run Visual Studio Solution, Verify Table Data using Storage Explorer, and Verify Application Insights Data
-
Using Visual Studio, update the
local.settings.json
andFunctions1.cs
files with information copied during previous lab objectives as well as the following code:public static class Function1 { [FunctionName("Function1")] [return: Table("<TABLE_NAME>", Connection = "StorageConnectionAppSetting")] public static SampleData Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; return new SampleData() { PartitionKey = "Http", RowKey = Guid.NewGuid().ToString(), Text = name }; } } public class SampleData : TableEntity { public string Text { get; set; } }
-
Run the updated function.
-
Using a web browser, test the updated function.
-
Verify the data is stored in the table successfully using Azure Storage Explorer.
-
Review the telemetry data using Application Insights.
-
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.