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#.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- 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.
- 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.
- 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.