Skip to content

Commit

Permalink
Merge pull request #749 from MicrosoftLearning/dotnet8-prep
Browse files Browse the repository at this point in the history
Dotnet 8 labs launch
  • Loading branch information
JeffKoMS authored Jan 26, 2024
2 parents 41bd211 + eafd95f commit f4673c5
Show file tree
Hide file tree
Showing 268 changed files with 152,536 additions and 1,238 deletions.
25 changes: 25 additions & 0 deletions Allfiles/Labs/01/Starter/API/API.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "Api.csproj", "{05767BB4-C22D-4F7A-BD47-B6C7D347F4BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{05767BB4-C22D-4F7A-BD47-B6C7D347F4BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05767BB4-C22D-4F7A-BD47-B6C7D347F4BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05767BB4-C22D-4F7A-BD47-B6C7D347F4BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05767BB4-C22D-4F7A-BD47-B6C7D347F4BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BAFEAA17-5F2E-452B-84F3-7555D3567EED}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Allfiles/Labs/01/Starter/API/Api.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.12.0" />
Expand Down
Binary file modified Allfiles/Labs/01/Starter/API/api.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Allfiles/Labs/01/Starter/Web/Web.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
25 changes: 25 additions & 0 deletions Allfiles/Labs/01/Starter/Web/Web.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "Web.csproj", "{C48CAA05-3E5D-4A41-B5B6-0C2D943831BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C48CAA05-3E5D-4A41-B5B6-0C2D943831BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C48CAA05-3E5D-4A41-B5B6-0C2D943831BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C48CAA05-3E5D-4A41-B5B6-0C2D943831BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C48CAA05-3E5D-4A41-B5B6-0C2D943831BD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5D1796EB-4D97-47F6-B085-F69BE733E87A}
EndGlobalSection
EndGlobal
Binary file modified Allfiles/Labs/01/Starter/Web/web.zip
Binary file not shown.
38 changes: 27 additions & 11 deletions Allfiles/Labs/02/Solution/func/Echo.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.AspNetCore.Http;
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

public static class Echo
namespace func
{
[FunctionName("Echo")]
public static IActionResult Run(
[HttpTrigger("POST")] HttpRequest request,
ILogger logger)
public class Echo
{
logger.LogInformation("Received a request");
return new OkObjectResult(request.Body);
private readonly ILogger _logger;

public Echo(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<Echo>();
}

[Function("Echo")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");

var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");

StreamReader reader = new StreamReader(req.Body);
string requestBody = reader.ReadToEnd();
response.WriteString(requestBody);

return response;
}
}
}
}
45 changes: 33 additions & 12 deletions Allfiles/Labs/02/Solution/func/GetSettingInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
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);
}
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace func
{
public class GetSettingInfo
{
private readonly ILogger _logger;

public GetSettingInfo(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<GetSettingInfo>();
}

[Function("GetSettingInfo")]
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
[BlobInput("content/settings.json", Connection = "AzureWebJobsStorage")] string blobContent
)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");
_logger.LogInformation($"{blobContent}");

var response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");

response.WriteString($"{blobContent}");

return response;
}
}
}
7 changes: 7 additions & 0 deletions Allfiles/Labs/02/Solution/func/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();

host.Run();
37 changes: 30 additions & 7 deletions Allfiles/Labs/02/Solution/func/Recurring.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace func
{
public static class Recurring
public class Recurring
{
[FunctionName("Recurring")]
public static void Run([TimerTrigger("*/30 * * * * *")]TimerInfo myTimer, ILogger log)
private readonly ILogger _logger;

public Recurring(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<Recurring>();
}

[Function("Recurring")]
public void Run([TimerTrigger("0 */2 * * * *")] MyInfo myTimer)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
}
}
}

public class MyInfo
{
public MyScheduleStatus ScheduleStatus { get; set; }

public bool IsPastDue { get; set; }
}

public class MyScheduleStatus
{
public DateTime Last { get; set; }

public DateTime Next { get; set; }

public DateTime LastUpdated { get; set; }
}
}
17 changes: 13 additions & 4 deletions Allfiles/Labs/02/Solution/func/func.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.14.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
Expand All @@ -16,4 +22,7 @@
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
7 changes: 4 additions & 3 deletions Allfiles/Labs/02/Solution/func/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
}
}
4 changes: 2 additions & 2 deletions Allfiles/Labs/02/Solution/func/local.settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "<storage-connection-string>",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
}
}
Loading

0 comments on commit f4673c5

Please sign in to comment.