Skip to content

Commit

Permalink
updates to devcontainer and code to .net8
Browse files Browse the repository at this point in the history
  • Loading branch information
madebygps committed Nov 20, 2023
1 parent 24479f3 commit f550edf
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 96 deletions.
64 changes: 32 additions & 32 deletions src/GetResume.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace Company.Function
{
public class GetResume
{
private readonly ILogger _logger;

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

[Function("GetResume")]
public HttpResponseData Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[BlobInput("resume/myresume.json")] string myResume)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");

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

response.WriteString(myResume);

return response;
}
}
}
using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.Logging;

namespace Company.Function
{
public class GetResume
{
private readonly ILogger _logger;

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

[Function("GetResume")]
public HttpResponseData Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[BlobInput("resume/myresume.json")] string myResume)
{
_logger.LogInformation("C# HTTP trigger function processed a request.");

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

response.WriteString(myResume);

return response;
}
}
}
14 changes: 7 additions & 7 deletions src/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.Extensions.Hosting;

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

host.Run();
using Microsoft.Extensions.Hosting;

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

host.Run();
16 changes: 8 additions & 8 deletions src/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"profiles": {
"serverless_resume_api": {
"commandName": "Project",
"commandLineArgs": "--port 7172",
"launchBrowser": false
}
}
{
"profiles": {
"serverless_resume_api": {
"commandName": "Project",
"commandLineArgs": "--port 7172",
"launchBrowser": false
}
}
}
30 changes: 15 additions & 15 deletions src/host.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensions": {
"http": {
"routePrefix": ""
}
}
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensions": {
"http": {
"routePrefix": ""
}
}
}
12 changes: 6 additions & 6 deletions src/local.settings.sample.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AzureWebJobsStorage": ""
}
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"AzureWebJobsStorage": ""
}
}
61 changes: 33 additions & 28 deletions src/serverless-resume-api.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>serverless_resume_api</RootNamespace>
<UserSecretsId>f1064ac0-4d4a-4f05-99f7-e19dae7d467e</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>serverless_resume_api</RootNamespace>
<UserSecretsId>f1064ac0-4d4a-4f05-99f7-e19dae7d467e</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" Version="6.2.0" />

<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />

</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# set to 9 or 10
DEBIAN_VERSION=10

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/$DEBIAN_VERSION/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list

sudo apt-get update
sudo apt-get install azure-functions-core-tools-4

0 comments on commit f550edf

Please sign in to comment.