Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/MadCoderAzureFunctionsDemo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and deploy .NET Core application to Function App MadCoderAzureFunctionsDemo
on:
pull_request:
branches:
- Release
env:
AZURE_FUNCTIONAPP_NAME: MadCoderAzureFunctionsDemo
AZURE_FUNCTIONAPP_PACKAGE_PATH: .\published
CONFIGURATION: Release
DOTNET_CORE_VERSION: 3.1.x
WORKING_DIRECTORY: ''
DOTNET_CORE_VERSION_INPROC: ''
jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- uses: actions/checkout@Release
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Setup .NET Core (for inproc extensions)
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION_INPROC }}
- name: Restore
run: dotnet restore "${{ env.WORKING_DIRECTORY }}"
- name: Build
run: dotnet build "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Publish
run: dotnet publish "${{ env.WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}"
- name: Deploy to Azure Function App
uses: Azure/functions-action@v1
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
publish-profile: ${{ secrets.MADCODERAZUREFUNCTIONSDEMO_FFFF }}
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
1 change: 1 addition & 0 deletions AzureFunctionsDemo/AzureFunctionsDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
</ItemGroup>
<ItemGroup>
Expand Down
151 changes: 151 additions & 0 deletions AzureFunctionsDemo/GitMonitorApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace AzureFunctionsDemo
{
public static class GitMonitorApp
{
[FunctionName("GitMonitorApp")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("Git Monitor App");

string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject<Rootobject>(requestBody);

log.LogInformation(requestBody);

return new OkResult();
}
}

public class Rootobject
{
public Authorization authorization { get; set; }
public string caller { get; set; }
public string channels { get; set; }
public Claims claims { get; set; }
public string correlationId { get; set; }
public string description { get; set; }
public string eventDataId { get; set; }
public Eventname eventName { get; set; }
public Category category { get; set; }
public DateTime eventTimestamp { get; set; }
public string id { get; set; }
public string level { get; set; }
public string operationId { get; set; }
public Operationname operationName { get; set; }
public string resourceGroupName { get; set; }
public Resourceprovidername resourceProviderName { get; set; }
public Resourcetype resourceType { get; set; }
public string resourceId { get; set; }
public Status status { get; set; }
public Substatus subStatus { get; set; }
public DateTime submissionTimestamp { get; set; }
public string subscriptionId { get; set; }
public string tenantId { get; set; }
public Properties properties { get; set; }
public object[] relatedEvents { get; set; }
}

public class Authorization
{
public string action { get; set; }
public string scope { get; set; }
}

public class Claims
{
public string aud { get; set; }
public string iss { get; set; }
public string iat { get; set; }
public string nbf { get; set; }
public string exp { get; set; }
public string httpschemasmicrosoftcomclaimsauthnclassreference { get; set; }
public string aio { get; set; }
public string altsecid { get; set; }
public string httpschemasmicrosoftcomclaimsauthnmethodsreferences { get; set; }
public string appid { get; set; }
public string appidacr { get; set; }
public string httpschemasxmlsoaporgws200505identityclaimsemailaddress { get; set; }
public string httpschemasxmlsoaporgws200505identityclaimssurname { get; set; }
public string httpschemasxmlsoaporgws200505identityclaimsgivenname { get; set; }
public string groups { get; set; }
public string httpschemasmicrosoftcomidentityclaimsidentityprovider { get; set; }
public string ipaddr { get; set; }
public string name { get; set; }
public string httpschemasmicrosoftcomidentityclaimsobjectidentifier { get; set; }
public string puid { get; set; }
public string rh { get; set; }
public string httpschemasmicrosoftcomidentityclaimsscope { get; set; }
public string httpschemasxmlsoaporgws200505identityclaimsnameidentifier { get; set; }
public string httpschemasmicrosoftcomidentityclaimstenantid { get; set; }
public string httpschemasxmlsoaporgws200505identityclaimsname { get; set; }
public string uti { get; set; }
public string ver { get; set; }
public string wids { get; set; }
public string xms_tcdt { get; set; }
}

public class Eventname
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Category
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Operationname
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Resourceprovidername
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Resourcetype
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Status
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Substatus
{
public string value { get; set; }
public string localizedValue { get; set; }
}

public class Properties
{
public string statusCode { get; set; }
public object serviceRequestId { get; set; }
public string eventCategory { get; set; }
public string entity { get; set; }
public string message { get; set; }
public string hierarchy { get; set; }
}

}
5 changes: 5 additions & 0 deletions AzureFunctionsDemo/MyInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"FirstName": "Sudhananda",
"LastName": "Biswas",
"Designation": "Jr. Software Engineer"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "MadCoderAzureFunctionsDemoResourceGroup",
"metadata": {
"_parameterType": "resourceGroup",
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "centralindia",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource group. Resource groups could have different location than resources."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('AzureFunctionsDemo', subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "AzureFunctionsDemo",
"type": "microsoft.insights/components",
"location": "[parameters('resourceLocation')]",
"kind": "web",
"properties": {},
"apiVersion": "2015-05-01"
}
]
}
}
}
],
"metadata": {
"_dependencyType": "appInsights.azure"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "MadCoderAzureFunctionsDemoResourceGroup",
"metadata": {
"_parameterType": "resourceGroup",
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "centralindia",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource group. Resource groups could have different location than resources."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('mcoderazurefunctionsdemo', subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "Storage",
"name": "mcoderazurefunctionsdemo",
"type": "Microsoft.Storage/storageAccounts",
"location": "[parameters('resourceLocation')]",
"apiVersion": "2017-10-01"
}
]
}
}
}
],
"metadata": {
"_dependencyType": "storage.azure"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dependencies": {
"storage1": {
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.Storage/storageAccounts/mcoderazurefunctionsdemo",
"type": "storage.azure",
"connectionId": "AzureWebJobsStorage"
},
"appInsights1": {
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourcegroups/[parameters('resourceGroupName')]/providers/Microsoft.Insights/components/AzureFunctionsDemo",
"type": "appInsights.azure",
"connectionId": "APPINSIGHTS_CONNECTIONSTRING",
"secretStore": "AzureAppSettings"
}
}
}
7 changes: 4 additions & 3 deletions AzureFunctionsDemo/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"dependencies": {
"appInsights1": {
"type": "appInsights"
},
"storage1": {
"type": "storage",
"connectionId": "AzureWebJobsStorage"
},
"appInsights1": {
"type": "appInsights",
"connectionId": "APPINSIGHTS_CONNECTIONSTRING"
}
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# AzureFunctionsDemo
Azure Functions Introduction

[![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)