From 69b32fc6f6b7e86d7c1ebc8cbb49adb5240e09b6 Mon Sep 17 00:00:00 2001 From: Zaid Ajaj Date: Fri, 4 May 2018 08:05:41 +0200 Subject: [PATCH] Enable AppInsights only if Deploy = 'azure' on Suave server Running `dotnet new SAFE --Server suave` adds app insights web part to main Suave web part which doesn't work because that only works if the `Deploy = "azure"`. This PR fixes it --- Content/src/Server/ServerSuave.fs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Content/src/Server/ServerSuave.fs b/Content/src/Server/ServerSuave.fs index 021c7000..23e6bc35 100644 --- a/Content/src/Server/ServerSuave.fs +++ b/Content/src/Server/ServerSuave.fs @@ -25,7 +25,7 @@ let config = let getInitCounter () : Async = async { return 42 } -let init : WebPart = +let webApi : WebPart = #if (Remoting) let counterProcotol = { getInitCounter = getInitCounter } @@ -43,9 +43,10 @@ let init : WebPart = } #endif -let webPart = +#if (Deploy == "azure") +let webApp = choose [ - init + webApi Filters.path "/" >=> Files.browseFileHome "index.html" Files.browseHome RequestErrors.NOT_FOUND "Not found!" @@ -53,5 +54,14 @@ let webPart = Azure.AppServices.addTraceListeners() Azure.AI.configure { AppInsightsKey = appInsightsKey; DeveloperMode = false; TrackDependencies = true } +#else +let webApp = + choose [ + webApi + Filters.path "/" >=> Files.browseFileHome "index.html" + Files.browseHome + RequestErrors.NOT_FOUND "Not found!" + ] +#endif -startWebServer config webPart \ No newline at end of file +startWebServer config webApp