Skip to content

Commit

Permalink
Merge pull request #99 from MicrosoftLearning/functions-update
Browse files Browse the repository at this point in the history
Prep for New Azure Functions Labs
  • Loading branch information
Sidney Andrews authored Oct 7, 2020
2 parents 57c962e + b740188 commit 59785b4
Show file tree
Hide file tree
Showing 19 changed files with 1,911 additions and 1,399 deletions.
16 changes: 16 additions & 0 deletions Allfiles/Labs/02/Solution/func/Echo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;

public static class Echo
{
[FunctionName("Echo")]
public static IActionResult Run(
[HttpTrigger("POST")] HttpRequest request,
ILogger logger)
{
logger.LogInformation("Received a request");
return new OkObjectResult(request.Body);
}
}
12 changes: 12 additions & 0 deletions Allfiles/Labs/02/Solution/func/GetSettingInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;

public static class GetSettingInfo
{
[FunctionName("GetSettingInfo")]
public static IActionResult Run(
[HttpTrigger("GET")] HttpRequest request,
[Blob("content/settings.json")] string json)
=> new OkObjectResult(json);
}
16 changes: 16 additions & 0 deletions Allfiles/Labs/02/Solution/func/Recurring.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace func
{
public static class Recurring
{
[FunctionName("Recurring")]
public static void Run([TimerTrigger("*/30 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
19 changes: 19 additions & 0 deletions Allfiles/Labs/02/Solution/func/func.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions Allfiles/Labs/02/Solution/func/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
}
}
7 changes: 7 additions & 0 deletions Allfiles/Labs/02/Solution/func/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "<storage-connection-string>",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
File renamed without changes.
4 changes: 2 additions & 2 deletions Allfiles/Labs/02/Starter/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"id": "21e46d2b2b926cba031a23c6919"
},
"notifications": {
"email": "Anais85@outlook.com",
"phone": "751.757.2014 x4151"
"email": "joseph.price@contoso.com",
"phone": "(425) 555-0162 x4151"
}
}
19 changes: 19 additions & 0 deletions Allfiles/Labs/07/Solution/func/FileParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Azure.Storage.Blobs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.AspNetCore.Http;
using System;
using System.Threading.Tasks;

public static class FileParser
{
[FunctionName("FileParser")]
public static async Task<IActionResult> Run(
[HttpTrigger("GET")] HttpRequest request)
{
string connectionString = Environment.GetEnvironmentVariable("StorageConnectionString");
BlobClient blob = new BlobClient(connectionString, "drop", "records.json");
var response = await blob.DownloadAsync();
return new FileStreamResult(response?.Value?.Content, response?.Value?.ContentType);
}
}
19 changes: 19 additions & 0 deletions Allfiles/Labs/07/Solution/func/func.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.6.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions Allfiles/Labs/07/Solution/func/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
}
}
8 changes: 8 additions & 0 deletions Allfiles/Labs/07/Solution/func/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"StorageConnectionString": "[TEST VALUE]"
}
}
File renamed without changes.
Loading

0 comments on commit 59785b4

Please sign in to comment.