Skip to content

Commit b0093d0

Browse files
committed
init
1 parent f3160ac commit b0093d0

8 files changed

+179
-0
lines changed

.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions",
4+
"ms-dotnettools.csharp"
5+
]
6+
}

.vscode/launch.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to .NET Functions",
6+
"type": "coreclr",
7+
"request": "attach",
8+
"processId": "${command:azureFunctions.pickProcess}"
9+
}
10+
]
11+
}

.vscode/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"azureFunctions.deploySubpath": "bin/Release/netcoreapp3.1/publish",
3+
"azureFunctions.projectLanguage": "C#",
4+
"azureFunctions.projectRuntime": "~3",
5+
"debug.internalConsoleOptions": "neverOpen",
6+
"azureFunctions.preDeployTask": "publish"
7+
}

.vscode/tasks.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "clean",
6+
"command": "dotnet",
7+
"args": [
8+
"clean",
9+
"/property:GenerateFullPaths=true",
10+
"/consoleloggerparameters:NoSummary"
11+
],
12+
"type": "process",
13+
"problemMatcher": "$msCompile"
14+
},
15+
{
16+
"label": "build",
17+
"command": "dotnet",
18+
"args": [
19+
"build",
20+
"/property:GenerateFullPaths=true",
21+
"/consoleloggerparameters:NoSummary"
22+
],
23+
"type": "process",
24+
"dependsOn": "clean",
25+
"group": {
26+
"kind": "build",
27+
"isDefault": true
28+
},
29+
"problemMatcher": "$msCompile"
30+
},
31+
{
32+
"label": "clean release",
33+
"command": "dotnet",
34+
"args": [
35+
"clean",
36+
"--configuration",
37+
"Release",
38+
"/property:GenerateFullPaths=true",
39+
"/consoleloggerparameters:NoSummary"
40+
],
41+
"type": "process",
42+
"problemMatcher": "$msCompile"
43+
},
44+
{
45+
"label": "publish",
46+
"command": "dotnet",
47+
"args": [
48+
"publish",
49+
"--configuration",
50+
"Release",
51+
"/property:GenerateFullPaths=true",
52+
"/consoleloggerparameters:NoSummary"
53+
],
54+
"type": "process",
55+
"dependsOn": "clean release",
56+
"problemMatcher": "$msCompile"
57+
},
58+
{
59+
"type": "func",
60+
"dependsOn": "build",
61+
"options": {
62+
"cwd": "${workspaceFolder}/bin/Debug/netcoreapp3.1"
63+
},
64+
"command": "host start",
65+
"isBackground": true,
66+
"problemMatcher": "$func-dotnet-watch"
67+
}
68+
]
69+
}

HttpTrigger.cs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using Microsoft.AspNetCore.Mvc;
5+
using Microsoft.Azure.WebJobs;
6+
using Microsoft.Azure.WebJobs.Extensions.Http;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.Extensions.Logging;
9+
using Newtonsoft.Json;
10+
11+
namespace Company.Function
12+
{
13+
public static class HttpTrigger
14+
{
15+
[FunctionName("HttpTrigger")]
16+
public static async Task<IActionResult> Run(
17+
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
18+
ILogger log)
19+
{
20+
log.LogInformation("C# HTTP trigger function processed a request.");
21+
22+
string name = req.Query["name"];
23+
24+
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
25+
dynamic data = JsonConvert.DeserializeObject(requestBody);
26+
name = name ?? data?.name;
27+
28+
string responseMessage = string.IsNullOrEmpty(name)
29+
? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
30+
: $"Hello, {name}. This HTTP triggered function executed successfully.";
31+
32+
return new OkObjectResult(responseMessage);
33+
}
34+
}
35+
}

ServiceBusQueueTrigger.cs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using Microsoft.Azure.WebJobs;
3+
using Microsoft.Azure.WebJobs.Host;
4+
using Microsoft.Extensions.Logging;
5+
6+
namespace Company.Function
7+
{
8+
public static class ServiceBusQueueTrigger
9+
{
10+
[FunctionName("ServiceBusQueueTrigger")]
11+
public static void Run([ServiceBusTrigger("queue", Connection = "SERVICEBUS_CONNECTION")]string myQueueItem, ILogger log)
12+
{
13+
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
14+
}
15+
}
16+
}

host.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "2.0",
3+
"logging": {
4+
"applicationInsights": {
5+
"samplingExcludedTypes": "Request",
6+
"samplingSettings": {
7+
"isEnabled": true
8+
}
9+
},
10+
"logLevel": {
11+
"default": "Error",
12+
"Host.Results": "Information"
13+
}
14+
}
15+
}

vnet-tutorial.csproj

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
5+
<RootNamespace>vnet_tutorial</RootNamespace>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.0" />
9+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
10+
</ItemGroup>
11+
<ItemGroup>
12+
<None Update="host.json">
13+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14+
</None>
15+
<None Update="local.settings.json">
16+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17+
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
18+
</None>
19+
</ItemGroup>
20+
</Project>

0 commit comments

Comments
 (0)