Add app insights to the relevant C#/F# examples
MODIFY
azure-cs-appservice/AppServiceStack.cs
azure-cs-appservice/AppServiceStack.cs
// Copyright 2016-2020, Pulumi Corporation. All rights reserved.
using Pulumi;
+using Pulumi.Azure.AppInsights;
using Pulumi.Azure.AppService;
using Pulumi.Azure.AppService.Inputs;
using Pulumi.Azure.Core;
@@ -47,6 +48,12 @@ class AppServiceStack : Stack
var codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount);
+ var appInsights = new Insights("appInsights", new InsightsArgs
+ {
+ ApplicationType = "web",
+ ResourceGroupName = resourceGroup.Name
+ });
+
var config = new Config();
var username = config.Get("sqlAdmin") ?? "pulumi";
var password = config.RequireSecret("sqlPassword");
@@ -72,6 +79,9 @@ class AppServiceStack : Stack
AppSettings =
{
{"WEBSITE_RUN_FROM_PACKAGE", codeBlobUrl},
+ {"APPINSIGHTS_INSTRUMENTATIONKEY", appInsights.InstrumentationKey},
+ {"APPLICATIONINSIGHTS_CONNECTION_STRING", appInsights.InstrumentationKey.Apply(key => $"InstrumentationKey={key}")},
+ {"ApplicationInsightsAgent_EXTENSION_VERSION", "~2"},
},
ConnectionStrings =
{

MODIFY
azure-fs-appservice/Program.fs
azure-fs-appservice/Program.fs
open Pulumi
open Pulumi.FSharp
+open Pulumi.Azure.AppInsights
open Pulumi.Azure.AppService
open Pulumi.Azure.AppService.Inputs
open Pulumi.Azure.Core
@@ -43,6 +44,12 @@ let infra () =
let codeBlobUrl = SharedAccessSignature.SignedBlobReadUrl(blob, storageAccount)
+ let appInsights =
+ Insights("appInsights",
+ InsightsArgs
+ (ApplicationType = input "web",
+ ResourceGroupName = io resourceGroup.Name))
+
let config = Config()
let username = config.Get "sqlAdmin"
let password = config.RequireSecret "sqlPassword"
@@ -74,12 +81,22 @@ let infra () =
Type = input "SQLAzure",
Value = io connectionString)
+ let appInsightsConnectionString =
+ appInsights.InstrumentationKey
+ |> Outputs.apply(fun (key) ->
+ sprintf "InstrumentationKey=%s" key)
+
let app =
AppService("app",
AppServiceArgs
(ResourceGroupName = io resourceGroup.Name,
AppServicePlanId = io appServicePlan.Id,
- AppSettings = inputMap ["WEBSITE_RUN_FROM_PACKAGE", io codeBlobUrl],
+ AppSettings = inputMap
+ ["WEBSITE_RUN_FROM_PACKAGE", io codeBlobUrl;
+ "APPINSIGHTS_INSTRUMENTATIONKEY", io appInsights.InstrumentationKey;
+ "APPLICATIONINSIGHTS_CONNECTION_STRING", io appInsightsConnectionString;
+ "ApplicationInsightsAgent_EXTENSION_VERSION", input "~2"],
+
ConnectionStrings = inputList [input connectionStringSetting]))
dict [("endpoint", app.DefaultSiteHostname :> obj)]

Add app insights to the relevant C#/F# examples (#756)