Skip to content

Commit aee1086

Browse files
authored
Merge pull request #1148 from CompositionalIT/modern-app-insights
Add support to Log Analytics for Web App and Functions.
2 parents 52d23a0 + ec0bad2 commit aee1086

File tree

10 files changed

+239
-91
lines changed

10 files changed

+239
-91
lines changed

Farmer.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.29201.188
@@ -67,6 +67,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tutorials", "tutorials", "{
6767
samples\scripts\tutorials\webapp-keyvault.fsx = samples\scripts\tutorials\webapp-keyvault.fsx
6868
EndProjectSection
6969
EndProject
70+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SampleApp", "samples\SampleApp\SampleApp.fsproj", "{4FA93ACF-25E8-4469-A2AC-4B339675EAF7}"
71+
EndProject
7072
Global
7173
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7274
Debug|Any CPU = Debug|Any CPU
@@ -81,13 +83,18 @@ Global
8183
{D68F5B81-6F18-4FC7-B9FD-2113EE7614CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
8284
{D68F5B81-6F18-4FC7-B9FD-2113EE7614CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
8385
{D68F5B81-6F18-4FC7-B9FD-2113EE7614CE}.Release|Any CPU.Build.0 = Release|Any CPU
86+
{4FA93ACF-25E8-4469-A2AC-4B339675EAF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87+
{4FA93ACF-25E8-4469-A2AC-4B339675EAF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
88+
{4FA93ACF-25E8-4469-A2AC-4B339675EAF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
89+
{4FA93ACF-25E8-4469-A2AC-4B339675EAF7}.Release|Any CPU.Build.0 = Release|Any CPU
8490
EndGlobalSection
8591
GlobalSection(SolutionProperties) = preSolution
8692
HideSolutionNode = FALSE
8793
EndGlobalSection
8894
GlobalSection(NestedProjects) = preSolution
8995
{C3991DD2-B728-4EDD-ACD1-2C1470309481} = {47438D72-1C5F-49EB-B7E5-B597F565B14B}
9096
{0053093F-A18C-4FAC-A138-9F5D60CFA24F} = {C3991DD2-B728-4EDD-ACD1-2C1470309481}
97+
{4FA93ACF-25E8-4469-A2AC-4B339675EAF7} = {47438D72-1C5F-49EB-B7E5-B597F565B14B}
9198
EndGlobalSection
9299
GlobalSection(ExtensibilityGlobals) = postSolution
93100
SolutionGuid = {63B0361D-FC8A-40CF-B988-5BE797ADD2CE}

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ Release Notes
22
=============
33
## vNext
44
* SQL Azure: Clean up Entra ID authentication support.
5+
* Web App: Support automatic creation of Workspace Based App Insights & Log Analytics.
6+
* Functions: Support automatic creation of Workspace Based App Insights & Log Analytics.
57
* Az: Update `ad` commands to work with latest (breaking) structure.
68
* PostgreSQL: Fix a number of issues around the introduction of Flexible Servers.
79

docs/content/api-overview/resources/functions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The Functions builder is used to create Azure Functions accounts. It abstracts t
2525
| link_to_unmanaged_storage_account | Do not create an automatic storage account; instead, link to an existing storage account that was created external to Farmer. |
2626
| https_only | Disables http for this functions app so that only HTTPS is used. |
2727
| ftp_state | Allows to enable or disable FTP and FTPS. |
28+
| Web App | use_workspace_based_app_insights | Instructs Farmer to use Workspace Based App Insights, which automatically comes with a Log Analytics instance. Both resources will be automatically created. |
2829
| app_insights_name | Sets the name of the automatically-created app insights instance. |
2930
| app_insights_off | Removes any automatic app insights creation, configuration and settings for this webapp. |
3031
| link_to_app_insights | Instead of creating a new AI instance, configure this webapp to point to another AI instance that you are managing yourself. |
@@ -52,7 +53,7 @@ The Functions builder is used to create Azure Functions accounts. It abstracts t
5253
| add_denied_ip_restriction | Adds an 'deny' rule for an ip |
5354
| link_to_vnet | Enable the VNET integration feature in azure where all outbound traffic from the function with be sent via the specified subnet. Use this operator when the given VNET is in the same deployment |
5455
| link_to_unmanaged_vnet | Enable the VNET integration feature in azure where all outbound traffic from the function with be sent via the specified subnet. Use this operator when the given VNET is *not* in the same deployment |
55-
| max_scale_out_limit | Maximum number of workers that a site can scale out to. This setting only applies to the Consumption and Elastic Premium Plans |
56+
| max_scale_out_limit | Maximum number of workers that a site can scale out to. This setting only applies to the Consumption and Elastic Premium Plans |
5657
#### Post-deployment Builder Keywords
5758
The Functions builder contains special commands that are executed *after* the ARM deployment is completed.
5859

docs/content/api-overview/resources/web-app.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The Web App builder is used to create Azure App Service accounts. It abstracts t
1919
| Web App | name | Sets the name of the web app. |
2020
| Web App | link_to_service_plan | Instructs Farmer to link this webapp to a Farmer service plan configuration defined elsewhere in your application, rather than creating a new one. |
2121
| Web App | link_to_unmanaged_service_plan | Instructs Farmer to link this webapp to an existing service plan that is externally managed, rather than creating a new one. |
22+
| Web App | use_workspace_based_app_insights | Instructs Farmer to use Workspace Based App Insights, which automatically comes with a Log Analytics instance. Both resources will be automatically created. |
2223
| Web App | app_insights_name | Sets the name of the automatically-created app insights instance. |
2324
| Web App | app_insights_off | Removes any automatic app insights creation, configuration and settings for this webapp. |
2425
| Web App | link_to_app_insights | Instructs Farmer to link this webapp to a Farmer App Insights configuration defined elsewhere in your application, rather than creating a new one. |

src/Farmer/Arm/Databricks.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Farmer.Arm.Databricks
33

44
open Farmer
55
open Farmer.Databricks
6-
open Farmer.Arm.Network
76
open System
87

98
let workspaces = ResourceType("Microsoft.Databricks/workspaces", "2018-04-01")

src/Farmer/Arm/Insights.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let componentsWorkspace = createComponents "2020-02-02"
1414
/// The type of AI instance to create.
1515
type InstanceKind =
1616
| Classic
17-
| Workspace of ResourceId
17+
| Workspace of workspace: ResourceId
1818

1919
member this.ResourceType =
2020
match this with

src/Farmer/Builders/Builders.Functions.fs

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type FunctionsConfig = {
116116
[<Obsolete("Prefer AppInsightsId instead as this property ignores resource groups")>]
117117
member this.AppInsightsName: ResourceName option =
118118
this.CommonWebConfig.AppInsights
119-
|> Option.map (fun ai -> ai.resourceId(this.Name.ResourceName).Name)
119+
|> Option.map (fun cfg -> cfg.AppInsights.resourceId(this.Name.ResourceName).Name)
120120

121121
/// Gets the Storage Account name for this functions app.
122122
[<Obsolete("Prefer StorageAccountId instead as this property ignores resource groups")>]
@@ -128,7 +128,7 @@ type FunctionsConfig = {
128128
/// Gets the App Insights resourceId for this functions app, if it exists.
129129
member this.AppInsightsId: ResourceId option =
130130
this.CommonWebConfig.AppInsights
131-
|> Option.map (fun ai -> ai.resourceId (this.Name.ResourceName))
131+
|> Option.map (fun cfg -> cfg.AppInsights.resourceId (this.Name.ResourceName))
132132

133133
/// Gets the Storage Account resourceId for this functions app.
134134
member this.StorageAccountId: ResourceId = this.StorageAccount.resourceId (this)
@@ -279,9 +279,10 @@ type FunctionsConfig = {
279279
Set [
280280
yield! this.Dependencies
281281

282-
match this.CommonWebConfig.AppInsights with
282+
match this.CommonWebConfig.AppInsights |> Option.map _.AppInsights with
283283
| Some(DependableResource this.Name.ResourceName resourceId) -> resourceId
284-
| _ -> ()
284+
| Some _
285+
| None -> ()
285286

286287
for setting in this.CommonWebConfig.Settings do
287288
match setting.Value with
@@ -388,22 +389,43 @@ type FunctionsConfig = {
388389
| _ -> ()
389390

390391
match this.CommonWebConfig.AppInsights with
391-
| Some(DeployableResource this.Name.ResourceName resourceId) -> {
392-
Name = resourceId.Name
393-
Location = location
394-
DisableIpMasking = false
395-
SamplingPercentage = 100
396-
Dependencies = Set.empty
397-
InstanceKind = Classic
398-
LinkedWebsite =
399-
match this.CommonWebConfig.OperatingSystem with
400-
| Windows -> Some this.Name.ResourceName
401-
| Linux -> None
402-
Tags = this.Tags
403-
}
404-
| Some _
392+
| Some appInsights ->
393+
match appInsights.AppInsights with
394+
| DeployableResource this.Name.ResourceName resourceId -> {
395+
Name = resourceId.Name
396+
Location = location
397+
DisableIpMasking = false
398+
SamplingPercentage = 100
399+
InstanceKind =
400+
match appInsights with
401+
| ClassicAi _ -> Classic
402+
| WorkspaceAi cfg -> Workspace(cfg.LogAnalytics.resourceId this.Name.ResourceName)
403+
Dependencies =
404+
match appInsights with
405+
| ClassicAi _ -> Set.empty
406+
| WorkspaceAi cfg -> Set [ cfg.LogAnalytics.resourceId this.Name.ResourceName ]
407+
LinkedWebsite = Some this.Name.ResourceName
408+
Tags = this.Tags
409+
}
410+
| _ -> ()
411+
412+
match appInsights with
413+
| ClassicAi _ -> ()
414+
| WorkspaceAi cfg ->
415+
match cfg.LogAnalytics with
416+
| DeployableResource this.Name.ResourceName resourceId -> {
417+
Name = resourceId.Name
418+
Location = location
419+
RetentionPeriod = None
420+
IngestionSupport = None
421+
QuerySupport = None
422+
DailyCap = None
423+
Tags = this.Tags
424+
}
425+
| _ -> ()
405426
| None -> ()
406427

428+
407429
match this.CommonWebConfig.IntegratedSubnet with
408430
| None -> ()
409431
| Some subnetRef -> {
@@ -432,7 +454,7 @@ type FunctionsBuilder() =
432454
FunctionsConfig.CommonWebConfig = {
433455
Name = WebAppName.Empty
434456
AlwaysOn = false
435-
AppInsights = Some(derived (fun name -> components.resourceId (name - "ai")))
457+
AppInsights = Some(ClassicAi(derived (fun name -> components.resourceId (name - "ai"))))
436458
ConnectionStrings = Map.empty
437459
Cors = None
438460
FTPState = None

0 commit comments

Comments
 (0)