Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 844aae1

Browse files
app insights instrumentation
1 parent 1b214aa commit 844aae1

File tree

8 files changed

+210
-2
lines changed

8 files changed

+210
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {}
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": "DigitalME",
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": "northeurope",
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('Digital-ME', 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/2015-01-01/deploymentTemplate.json#",
49+
"contentVersion": "1.0.0.0",
50+
"resources": [
51+
{
52+
"name": "Digital-ME",
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: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"metadata": {
5+
"_dependencyType": "appService.windows"
6+
},
7+
"parameters": {
8+
"resourceGroupName": {
9+
"type": "string",
10+
"defaultValue": "DigitalME",
11+
"metadata": {
12+
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
13+
}
14+
},
15+
"resourceGroupLocation": {
16+
"type": "string",
17+
"defaultValue": "northeurope",
18+
"metadata": {
19+
"description": "Location of the resource group. Resource groups could have different location than resources, however by default we use API versions from latest hybrid profile which support all locations for resource types we support."
20+
}
21+
},
22+
"resourceName": {
23+
"type": "string",
24+
"defaultValue": "Digital-ME",
25+
"metadata": {
26+
"description": "Name of the main resource to be created by this template."
27+
}
28+
},
29+
"resourceLocation": {
30+
"type": "string",
31+
"defaultValue": "[parameters('resourceGroupLocation')]",
32+
"metadata": {
33+
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
34+
}
35+
}
36+
},
37+
"variables": {
38+
"appServicePlan_name": "[concat('Plan', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
39+
"appServicePlan_ResourceId": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('resourceGroupName'), '/providers/Microsoft.Web/serverFarms/', variables('appServicePlan_name'))]"
40+
},
41+
"resources": [
42+
{
43+
"type": "Microsoft.Resources/resourceGroups",
44+
"name": "[parameters('resourceGroupName')]",
45+
"location": "[parameters('resourceGroupLocation')]",
46+
"apiVersion": "2019-10-01"
47+
},
48+
{
49+
"type": "Microsoft.Resources/deployments",
50+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat(parameters('resourceName'), subscription().subscriptionId)))]",
51+
"resourceGroup": "[parameters('resourceGroupName')]",
52+
"apiVersion": "2019-10-01",
53+
"dependsOn": [
54+
"[parameters('resourceGroupName')]"
55+
],
56+
"properties": {
57+
"mode": "Incremental",
58+
"template": {
59+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
60+
"contentVersion": "1.0.0.0",
61+
"resources": [
62+
{
63+
"location": "[parameters('resourceLocation')]",
64+
"name": "[parameters('resourceName')]",
65+
"type": "Microsoft.Web/sites",
66+
"apiVersion": "2015-08-01",
67+
"tags": {
68+
"[concat('hidden-related:', variables('appServicePlan_ResourceId'))]": "empty"
69+
},
70+
"dependsOn": [
71+
"[variables('appServicePlan_ResourceId')]"
72+
],
73+
"kind": "app",
74+
"properties": {
75+
"name": "[parameters('resourceName')]",
76+
"kind": "app",
77+
"httpsOnly": true,
78+
"reserved": false,
79+
"serverFarmId": "[variables('appServicePlan_ResourceId')]",
80+
"siteConfig": {
81+
"metadata": [
82+
{
83+
"name": "CURRENT_STACK",
84+
"value": "dotnetcore"
85+
}
86+
]
87+
}
88+
},
89+
"identity": {
90+
"type": "SystemAssigned"
91+
}
92+
},
93+
{
94+
"location": "[parameters('resourceLocation')]",
95+
"name": "[variables('appServicePlan_name')]",
96+
"type": "Microsoft.Web/serverFarms",
97+
"apiVersion": "2015-08-01",
98+
"sku": {
99+
"name": "S1",
100+
"tier": "Standard",
101+
"family": "S",
102+
"size": "S1"
103+
},
104+
"properties": {
105+
"name": "[variables('appServicePlan_name')]"
106+
}
107+
}
108+
]
109+
}
110+
}
111+
}
112+
]
113+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dependencies": {
3+
"appInsights1": {
4+
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/microsoft.insights/components/Digital-ME",
5+
"type": "appInsights.azure",
6+
"connectionId": "APPINSIGHTS_INSTRUMENTATIONKEY",
7+
"secretStore": "AzureAppSettings"
8+
}
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"dependencies": {
3+
"appInsights1": {
4+
"type": "appInsights",
5+
"connectionId": "APPINSIGHTS_INSTRUMENTATIONKEY"
6+
}
7+
}
8+
}

src/Vs.BurgerPortaal.Server/Startup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void ConfigureServices(IServiceCollection services)
2323
services.AddRazorPages();
2424
services.AddServerSideBlazor();
2525
Initializer.Initialize(services);
26+
services.AddApplicationInsightsTelemetry(Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"]);
2627
}
2728

2829
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

src/Vs.BurgerPortaal.Server/Vs.BurgerPortaal.Server.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.14.0" />
1011
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
1112
</ItemGroup>
1213

src/Vs.BurgerPortaal.Server/appsettings.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"Microsoft.Hosting.Lifetime": "Information"
77
}
88
},
9-
"AllowedHosts": "*"
10-
}
9+
"AllowedHosts": "*",
10+
"ApplicationInsights": {
11+
"InstrumentationKey": "df469981-1943-4e5d-ac79-05921fd81427"
12+
}
13+
}

0 commit comments

Comments
 (0)