Skip to content

Commit bc3de1b

Browse files
authored
Merge pull request #1 from madcoderBubt/master
master to release pull request
2 parents 22ed2d2 + e986066 commit bc3de1b

File tree

9 files changed

+354
-3
lines changed

9 files changed

+354
-3
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and deploy .NET Core application to Function App MadCoderAzureFunctionsDemo
2+
on:
3+
pull_request:
4+
branches:
5+
- Release
6+
env:
7+
AZURE_FUNCTIONAPP_NAME: MadCoderAzureFunctionsDemo
8+
AZURE_FUNCTIONAPP_PACKAGE_PATH: .\published
9+
CONFIGURATION: Release
10+
DOTNET_CORE_VERSION: 3.1.x
11+
WORKING_DIRECTORY: ''
12+
DOTNET_CORE_VERSION_INPROC: ''
13+
jobs:
14+
build-and-deploy:
15+
runs-on: windows-latest
16+
steps:
17+
- uses: actions/checkout@Release
18+
- name: Setup .NET Core
19+
uses: actions/setup-dotnet@v1
20+
with:
21+
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
22+
- name: Setup .NET Core (for inproc extensions)
23+
uses: actions/setup-dotnet@v1
24+
with:
25+
dotnet-version: ${{ env.DOTNET_CORE_VERSION_INPROC }}
26+
- name: Restore
27+
run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
28+
- name: Build
29+
run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
30+
- name: Publish
31+
run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}"
32+
- name: Deploy to Azure Function App
33+
uses: Azure/functions-action@v1
34+
with:
35+
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
36+
publish-profile: ${{ secrets.MADCODERAZUREFUNCTIONSDEMO_FFFF }}
37+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}

AzureFunctionsDemo/AzureFunctionsDemo.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
55
</PropertyGroup>
66
<ItemGroup>
7+
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
78
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
89
</ItemGroup>
910
<ItemGroup>

AzureFunctionsDemo/GitMonitorApp.cs

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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 AzureFunctionsDemo
12+
{
13+
public static class GitMonitorApp
14+
{
15+
[FunctionName("GitMonitorApp")]
16+
public static async Task<IActionResult> Run(
17+
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
18+
ILogger log)
19+
{
20+
log.LogInformation("Git Monitor App");
21+
22+
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
23+
dynamic data = JsonConvert.DeserializeObject<Rootobject>(requestBody);
24+
25+
log.LogInformation(requestBody);
26+
27+
return new OkResult();
28+
}
29+
}
30+
31+
public class Rootobject
32+
{
33+
public Authorization authorization { get; set; }
34+
public string caller { get; set; }
35+
public string channels { get; set; }
36+
public Claims claims { get; set; }
37+
public string correlationId { get; set; }
38+
public string description { get; set; }
39+
public string eventDataId { get; set; }
40+
public Eventname eventName { get; set; }
41+
public Category category { get; set; }
42+
public DateTime eventTimestamp { get; set; }
43+
public string id { get; set; }
44+
public string level { get; set; }
45+
public string operationId { get; set; }
46+
public Operationname operationName { get; set; }
47+
public string resourceGroupName { get; set; }
48+
public Resourceprovidername resourceProviderName { get; set; }
49+
public Resourcetype resourceType { get; set; }
50+
public string resourceId { get; set; }
51+
public Status status { get; set; }
52+
public Substatus subStatus { get; set; }
53+
public DateTime submissionTimestamp { get; set; }
54+
public string subscriptionId { get; set; }
55+
public string tenantId { get; set; }
56+
public Properties properties { get; set; }
57+
public object[] relatedEvents { get; set; }
58+
}
59+
60+
public class Authorization
61+
{
62+
public string action { get; set; }
63+
public string scope { get; set; }
64+
}
65+
66+
public class Claims
67+
{
68+
public string aud { get; set; }
69+
public string iss { get; set; }
70+
public string iat { get; set; }
71+
public string nbf { get; set; }
72+
public string exp { get; set; }
73+
public string httpschemasmicrosoftcomclaimsauthnclassreference { get; set; }
74+
public string aio { get; set; }
75+
public string altsecid { get; set; }
76+
public string httpschemasmicrosoftcomclaimsauthnmethodsreferences { get; set; }
77+
public string appid { get; set; }
78+
public string appidacr { get; set; }
79+
public string httpschemasxmlsoaporgws200505identityclaimsemailaddress { get; set; }
80+
public string httpschemasxmlsoaporgws200505identityclaimssurname { get; set; }
81+
public string httpschemasxmlsoaporgws200505identityclaimsgivenname { get; set; }
82+
public string groups { get; set; }
83+
public string httpschemasmicrosoftcomidentityclaimsidentityprovider { get; set; }
84+
public string ipaddr { get; set; }
85+
public string name { get; set; }
86+
public string httpschemasmicrosoftcomidentityclaimsobjectidentifier { get; set; }
87+
public string puid { get; set; }
88+
public string rh { get; set; }
89+
public string httpschemasmicrosoftcomidentityclaimsscope { get; set; }
90+
public string httpschemasxmlsoaporgws200505identityclaimsnameidentifier { get; set; }
91+
public string httpschemasmicrosoftcomidentityclaimstenantid { get; set; }
92+
public string httpschemasxmlsoaporgws200505identityclaimsname { get; set; }
93+
public string uti { get; set; }
94+
public string ver { get; set; }
95+
public string wids { get; set; }
96+
public string xms_tcdt { get; set; }
97+
}
98+
99+
public class Eventname
100+
{
101+
public string value { get; set; }
102+
public string localizedValue { get; set; }
103+
}
104+
105+
public class Category
106+
{
107+
public string value { get; set; }
108+
public string localizedValue { get; set; }
109+
}
110+
111+
public class Operationname
112+
{
113+
public string value { get; set; }
114+
public string localizedValue { get; set; }
115+
}
116+
117+
public class Resourceprovidername
118+
{
119+
public string value { get; set; }
120+
public string localizedValue { get; set; }
121+
}
122+
123+
public class Resourcetype
124+
{
125+
public string value { get; set; }
126+
public string localizedValue { get; set; }
127+
}
128+
129+
public class Status
130+
{
131+
public string value { get; set; }
132+
public string localizedValue { get; set; }
133+
}
134+
135+
public class Substatus
136+
{
137+
public string value { get; set; }
138+
public string localizedValue { get; set; }
139+
}
140+
141+
public class Properties
142+
{
143+
public string statusCode { get; set; }
144+
public object serviceRequestId { get; set; }
145+
public string eventCategory { get; set; }
146+
public string entity { get; set; }
147+
public string message { get; set; }
148+
public string hierarchy { get; set; }
149+
}
150+
151+
}

AzureFunctionsDemo/MyInfo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"FirstName": "Sudhananda",
3+
"LastName": "Biswas",
4+
"Designation": "Jr. Software Engineer"
5+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"resourceGroupName": {
6+
"type": "string",
7+
"defaultValue": "MadCoderAzureFunctionsDemoResourceGroup",
8+
"metadata": {
9+
"_parameterType": "resourceGroup",
10+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
11+
}
12+
},
13+
"resourceGroupLocation": {
14+
"type": "string",
15+
"defaultValue": "centralindia",
16+
"metadata": {
17+
"_parameterType": "location",
18+
"description": "Location of the resource group. Resource groups could have different location than resources."
19+
}
20+
},
21+
"resourceLocation": {
22+
"type": "string",
23+
"defaultValue": "[parameters('resourceGroupLocation')]",
24+
"metadata": {
25+
"_parameterType": "location",
26+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
27+
}
28+
}
29+
},
30+
"resources": [
31+
{
32+
"type": "Microsoft.Resources/resourceGroups",
33+
"name": "[parameters('resourceGroupName')]",
34+
"location": "[parameters('resourceGroupLocation')]",
35+
"apiVersion": "2019-10-01"
36+
},
37+
{
38+
"type": "Microsoft.Resources/deployments",
39+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('AzureFunctionsDemo', subscription().subscriptionId)))]",
40+
"resourceGroup": "[parameters('resourceGroupName')]",
41+
"apiVersion": "2019-10-01",
42+
"dependsOn": [
43+
"[parameters('resourceGroupName')]"
44+
],
45+
"properties": {
46+
"mode": "Incremental",
47+
"template": {
48+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
49+
"contentVersion": "1.0.0.0",
50+
"resources": [
51+
{
52+
"name": "AzureFunctionsDemo",
53+
"type": "microsoft.insights/components",
54+
"location": "[parameters('resourceLocation')]",
55+
"kind": "web",
56+
"properties": {},
57+
"apiVersion": "2015-05-01"
58+
}
59+
]
60+
}
61+
}
62+
}
63+
],
64+
"metadata": {
65+
"_dependencyType": "appInsights.azure"
66+
}
67+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"resourceGroupName": {
6+
"type": "string",
7+
"defaultValue": "MadCoderAzureFunctionsDemoResourceGroup",
8+
"metadata": {
9+
"_parameterType": "resourceGroup",
10+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
11+
}
12+
},
13+
"resourceGroupLocation": {
14+
"type": "string",
15+
"defaultValue": "centralindia",
16+
"metadata": {
17+
"_parameterType": "location",
18+
"description": "Location of the resource group. Resource groups could have different location than resources."
19+
}
20+
},
21+
"resourceLocation": {
22+
"type": "string",
23+
"defaultValue": "[parameters('resourceGroupLocation')]",
24+
"metadata": {
25+
"_parameterType": "location",
26+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
27+
}
28+
}
29+
},
30+
"resources": [
31+
{
32+
"type": "Microsoft.Resources/resourceGroups",
33+
"name": "[parameters('resourceGroupName')]",
34+
"location": "[parameters('resourceGroupLocation')]",
35+
"apiVersion": "2019-10-01"
36+
},
37+
{
38+
"type": "Microsoft.Resources/deployments",
39+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('mcoderazurefunctionsdemo', subscription().subscriptionId)))]",
40+
"resourceGroup": "[parameters('resourceGroupName')]",
41+
"apiVersion": "2019-10-01",
42+
"dependsOn": [
43+
"[parameters('resourceGroupName')]"
44+
],
45+
"properties": {
46+
"mode": "Incremental",
47+
"template": {
48+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
49+
"contentVersion": "1.0.0.0",
50+
"resources": [
51+
{
52+
"sku": {
53+
"name": "Standard_LRS",
54+
"tier": "Standard"
55+
},
56+
"kind": "Storage",
57+
"name": "mcoderazurefunctionsdemo",
58+
"type": "Microsoft.Storage/storageAccounts",
59+
"location": "[parameters('resourceLocation')]",
60+
"apiVersion": "2017-10-01"
61+
}
62+
]
63+
}
64+
}
65+
}
66+
],
67+
"metadata": {
68+
"_dependencyType": "storage.azure"
69+
}
70+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"dependencies": {
3+
"storage1": {
4+
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.Storage/storageAccounts/mcoderazurefunctionsdemo",
5+
"type": "storage.azure",
6+
"connectionId": "AzureWebJobsStorage"
7+
},
8+
"appInsights1": {
9+
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourcegroups/[parameters('resourceGroupName')]/providers/Microsoft.Insights/components/AzureFunctionsDemo",
10+
"type": "appInsights.azure",
11+
"connectionId": "APPINSIGHTS_CONNECTIONSTRING",
12+
"secretStore": "AzureAppSettings"
13+
}
14+
}
15+
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"dependencies": {
3-
"appInsights1": {
4-
"type": "appInsights"
5-
},
63
"storage1": {
74
"type": "storage",
85
"connectionId": "AzureWebJobsStorage"
6+
},
7+
"appInsights1": {
8+
"type": "appInsights",
9+
"connectionId": "APPINSIGHTS_CONNECTIONSTRING"
910
}
1011
}
1112
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# AzureFunctionsDemo
2+
Azure Functions Introduction
3+
4+
[![Build and deploy Azure Functions to MadCoderAzureFunctionsDemo](https://github.com/madcoderBubt/AzureFunctionsDemo/actions/workflows/MadCoderAzureFunctionsDemo.yml/badge.svg?branch=master)](https://github.com/madcoderBubt/AzureFunctionsDemo/actions/workflows/MadCoderAzureFunctionsDemo.yml)

0 commit comments

Comments
 (0)