@@ -22,6 +22,7 @@ import (
2222 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2323 "github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
2424 "github.com/hashicorp/terraform-provider-azurerm/internal/clients"
25+ "github.com/hashicorp/terraform-provider-azurerm/internal/features"
2526 "github.com/hashicorp/terraform-provider-azurerm/internal/services/applicationinsights/migration"
2627 "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
2728 "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
@@ -80,10 +81,10 @@ func resourceApplicationInsights() *pluginsdk.Resource {
8081 }, false ),
8182 },
8283
83- // NOTE: O+C A Log Analytics Workspace will be attached to the Application Insight by default, which should be computed=true
8484 "workspace_id" : {
85- Type : pluginsdk .TypeString ,
86- Optional : true ,
85+ Type : pluginsdk .TypeString ,
86+ Optional : true ,
87+ // NOTE: O+C A Log Analytics Workspace will be attached to the Application Insight by default, which should be computed=true
8788 Computed : true ,
8889 ValidateFunc : workspaces .ValidateWorkspaceID ,
8990 },
@@ -112,10 +113,10 @@ func resourceApplicationInsights() *pluginsdk.Resource {
112113 ValidateFunc : validation .FloatBetween (0 , 100 ),
113114 },
114115
115- "disable_ip_masking " : {
116+ "ip_masking_enabled " : {
116117 Type : pluginsdk .TypeBool ,
117118 Optional : true ,
118- Default : false ,
119+ Default : true ,
119120 },
120121
121122 "tags" : commonschema .Tags (),
@@ -127,9 +128,10 @@ func resourceApplicationInsights() *pluginsdk.Resource {
127128 ValidateFunc : validation .FloatAtLeast (0 ),
128129 },
129130
130- "daily_data_cap_notifications_disabled " : {
131+ "daily_data_cap_notifications_enabled " : {
131132 Type : pluginsdk .TypeBool ,
132133 Optional : true ,
134+ Default : true ,
133135 },
134136
135137 "app_id" : {
@@ -149,10 +151,10 @@ func resourceApplicationInsights() *pluginsdk.Resource {
149151 Sensitive : true ,
150152 },
151153
152- "local_authentication_disabled " : {
154+ "local_authentication_enabled " : {
153155 Type : pluginsdk .TypeBool ,
154156 Optional : true ,
155- Default : false ,
157+ Default : true ,
156158 },
157159
158160 "internet_ingestion_enabled" : {
@@ -174,6 +176,53 @@ func resourceApplicationInsights() *pluginsdk.Resource {
174176 },
175177 }
176178
179+ if ! features .FivePointOh () {
180+ resource .Schema ["local_authentication_disabled" ] = & pluginsdk.Schema {
181+ Type : pluginsdk .TypeBool ,
182+ Optional : true ,
183+ Computed : true ,
184+ Deprecated : "`local_authentication_disabled` has been deprecated in favour of `local_authentication_enabled` and will be removed in v5.0 of the AzureRM Provider" ,
185+ ConflictsWith : []string {"local_authentication_enabled" },
186+ }
187+
188+ resource .Schema ["local_authentication_enabled" ] = & pluginsdk.Schema {
189+ Type : pluginsdk .TypeBool ,
190+ Optional : true ,
191+ Computed : true ,
192+ ConflictsWith : []string {"local_authentication_disabled" },
193+ }
194+
195+ resource .Schema ["disable_ip_masking" ] = & pluginsdk.Schema {
196+ Type : pluginsdk .TypeBool ,
197+ Optional : true ,
198+ Computed : true ,
199+ Deprecated : "`disable_ip_masking` has been deprecated in favour of `ip_masking_enabled` and will be removed in v5.0 of the AzureRM Provider" ,
200+ ConflictsWith : []string {"ip_masking_enabled" },
201+ }
202+
203+ resource .Schema ["ip_masking_enabled" ] = & pluginsdk.Schema {
204+ Type : pluginsdk .TypeBool ,
205+ Optional : true ,
206+ Computed : true ,
207+ ConflictsWith : []string {"disable_ip_masking" },
208+ }
209+
210+ resource .Schema ["daily_data_cap_notifications_disabled" ] = & pluginsdk.Schema {
211+ Type : pluginsdk .TypeBool ,
212+ Optional : true ,
213+ Computed : true ,
214+ Deprecated : "`daily_data_cap_notifications_disabled` has been deprecated in favour of `daily_data_cap_notifications_enabled` and will be removed in v5.0 of the AzureRM Provider" ,
215+ ConflictsWith : []string {"daily_data_cap_notifications_enabled" },
216+ }
217+
218+ resource .Schema ["daily_data_cap_notifications_enabled" ] = & pluginsdk.Schema {
219+ Type : pluginsdk .TypeBool ,
220+ Optional : true ,
221+ Computed : true ,
222+ ConflictsWith : []string {"daily_data_cap_notifications_disabled" },
223+ }
224+ }
225+
177226 return resource
178227}
179228
@@ -211,13 +260,31 @@ func resourceApplicationInsightsCreate(d *pluginsdk.ResourceData, meta interface
211260 ApplicationId : pointer .To (id .ComponentName ),
212261 ApplicationType : components .ApplicationType (d .Get ("application_type" ).(string )),
213262 SamplingPercentage : pointer .To (d .Get ("sampling_percentage" ).(float64 )),
214- DisableIPMasking : pointer .To (d .Get ("disable_ip_masking " ).(bool )),
215- DisableLocalAuth : pointer .To (d .Get ("local_authentication_disabled " ).(bool )),
263+ DisableIPMasking : pointer .To (! d .Get ("ip_masking_enabled " ).(bool )),
264+ DisableLocalAuth : pointer .To (! d .Get ("local_authentication_enabled " ).(bool )),
216265 PublicNetworkAccessForIngestion : pointer .To (internetIngestionEnabled ),
217266 PublicNetworkAccessForQuery : pointer .To (internetQueryEnabled ),
218267 ForceCustomerStorageForProfiler : pointer .To (d .Get ("force_customer_storage_for_profiler" ).(bool )),
219268 }
220269
270+ if ! features .FivePointOh () {
271+ applicationInsightsComponentProperties .DisableIPMasking = pointer .To (false )
272+ if ! pluginsdk .IsExplicitlyNullInConfig (d , "ip_masking_enabled" ) {
273+ applicationInsightsComponentProperties .DisableIPMasking = pointer .To (! d .Get ("ip_masking_enabled" ).(bool ))
274+ }
275+ if ! pluginsdk .IsExplicitlyNullInConfig (d , "disable_ip_masking" ) {
276+ applicationInsightsComponentProperties .DisableIPMasking = pointer .To (d .Get ("disable_ip_masking" ).(bool ))
277+ }
278+
279+ applicationInsightsComponentProperties .DisableLocalAuth = pointer .To (false )
280+ if ! pluginsdk .IsExplicitlyNullInConfig (d , "local_authentication_enabled" ) {
281+ applicationInsightsComponentProperties .DisableLocalAuth = pointer .To (! d .Get ("local_authentication_enabled" ).(bool ))
282+ }
283+ if ! pluginsdk .IsExplicitlyNullInConfig (d , "local_authentication_disabled" ) {
284+ applicationInsightsComponentProperties .DisableLocalAuth = pointer .To (d .Get ("local_authentication_disabled" ).(bool ))
285+ }
286+ }
287+
221288 if workspaceRaw , ok := d .GetOk ("workspace_id" ); ok {
222289 workspaceID , err := workspaces .ParseWorkspaceID (workspaceRaw .(string ))
223290 if err != nil {
@@ -285,8 +352,15 @@ func resourceApplicationInsightsCreate(d *pluginsdk.ResourceData, meta interface
285352 applicationInsightsComponentBillingFeatures .DataVolumeCap .Cap = pointer .To (v .(float64 ))
286353 }
287354
288- if v , ok := d .GetOk ("daily_data_cap_notifications_disabled" ); ok {
289- applicationInsightsComponentBillingFeatures .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (v .(bool ))
355+ applicationInsightsComponentBillingFeatures .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (! d .Get ("daily_data_cap_notifications_enabled" ).(bool ))
356+ if ! features .FivePointOh () {
357+ applicationInsightsComponentBillingFeatures .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (false )
358+ if ! pluginsdk .IsExplicitlyNullInConfig (d , "daily_data_cap_notifications_enabled" ) {
359+ applicationInsightsComponentBillingFeatures .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (! d .Get ("daily_data_cap_notifications_enabled" ).(bool ))
360+ }
361+ if ! pluginsdk .IsExplicitlyNullInConfig (d , "daily_data_cap_notifications_disabled" ) {
362+ applicationInsightsComponentBillingFeatures .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (d .Get ("daily_data_cap_notifications_disabled" ).(bool ))
363+ }
290364 }
291365
292366 if _ , err = billingClient .ComponentCurrentBillingFeaturesUpdate (ctx , * billingId , applicationInsightsComponentBillingFeatures ); err != nil {
@@ -385,9 +459,15 @@ func resourceApplicationInsightsRead(d *pluginsdk.ResourceData, meta interface{}
385459 d .Set ("app_id" , props .AppId )
386460 d .Set ("instrumentation_key" , props .InstrumentationKey )
387461 d .Set ("sampling_percentage" , props .SamplingPercentage )
388- d .Set ("disable_ip_masking" , props .DisableIPMasking )
462+ d .Set ("ip_masking_enabled" , ! pointer .From (props .DisableIPMasking ))
463+ if ! features .FivePointOh () {
464+ d .Set ("disable_ip_masking" , pointer .From (props .DisableIPMasking ))
465+ }
389466 d .Set ("connection_string" , props .ConnectionString )
390- d .Set ("local_authentication_disabled" , props .DisableLocalAuth )
467+ d .Set ("local_authentication_enabled" , ! pointer .From (props .DisableLocalAuth ))
468+ if ! features .FivePointOh () {
469+ d .Set ("local_authentication_disabled" , pointer .From (props .DisableLocalAuth ))
470+ }
391471 d .Set ("internet_ingestion_enabled" , pointer .From (props .PublicNetworkAccessForIngestion ) == components .PublicNetworkAccessTypeEnabled )
392472 d .Set ("internet_query_enabled" , pointer .From (props .PublicNetworkAccessForQuery ) == components .PublicNetworkAccessTypeEnabled )
393473 d .Set ("force_customer_storage_for_profiler" , props .ForceCustomerStorageForProfiler )
@@ -407,7 +487,10 @@ func resourceApplicationInsightsRead(d *pluginsdk.ResourceData, meta interface{}
407487 if model := billingResp .Model ; model != nil {
408488 if props := model .DataVolumeCap ; props != nil {
409489 d .Set ("daily_data_cap_in_gb" , props .Cap )
410- d .Set ("daily_data_cap_notifications_disabled" , props .StopSendNotificationWhenHitCap )
490+ d .Set ("daily_data_cap_notifications_enabled" , ! pointer .From (props .StopSendNotificationWhenHitCap ))
491+ if ! features .FivePointOh () {
492+ d .Set ("daily_data_cap_notifications_disabled" , pointer .From (props .StopSendNotificationWhenHitCap ))
493+ }
411494 }
412495 }
413496
@@ -447,12 +530,24 @@ func resourceApplicationInsightsUpdate(d *pluginsdk.ResourceData, meta interface
447530 component .Properties .SamplingPercentage = pointer .To (d .Get ("sampling_percentage" ).(float64 ))
448531 }
449532
450- if d .HasChange ("disable_ip_masking" ) {
451- component .Properties .DisableIPMasking = pointer .To (d .Get ("disable_ip_masking" ).(bool ))
533+ if d .HasChange ("ip_masking_enabled" ) {
534+ component .Properties .DisableIPMasking = pointer .To (! d .Get ("ip_masking_enabled" ).(bool ))
535+ }
536+
537+ if ! features .FivePointOh () {
538+ if d .HasChange ("disable_ip_masking" ) {
539+ component .Properties .DisableIPMasking = pointer .To (d .Get ("disable_ip_masking" ).(bool ))
540+ }
541+ }
542+
543+ if d .HasChange ("local_authentication_enabled" ) {
544+ component .Properties .DisableLocalAuth = pointer .To (! d .Get ("local_authentication_enabled" ).(bool ))
452545 }
453546
454- if d .HasChange ("local_authentication_disabled" ) {
455- component .Properties .DisableLocalAuth = pointer .To (d .Get ("local_authentication_disabled" ).(bool ))
547+ if ! features .FivePointOh () {
548+ if d .HasChange ("local_authentication_disabled" ) {
549+ component .Properties .DisableLocalAuth = pointer .To (d .Get ("local_authentication_disabled" ).(bool ))
550+ }
456551 }
457552
458553 if d .HasChange ("internet_ingestion_enabled" ) {
@@ -527,8 +622,14 @@ func resourceApplicationInsightsUpdate(d *pluginsdk.ResourceData, meta interface
527622 billingProps .DataVolumeCap .Cap = pointer .To (d .Get ("daily_data_cap_in_gb" ).(float64 ))
528623 }
529624
530- if d .HasChange ("daily_data_cap_notifications_disabled" ) {
531- billingProps .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (d .Get ("daily_data_cap_notifications_disabled" ).(bool ))
625+ if d .HasChange ("daily_data_cap_notifications_enabled" ) {
626+ billingProps .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (! d .Get ("daily_data_cap_notifications_enabled" ).(bool ))
627+ }
628+
629+ if ! features .FivePointOh () {
630+ if d .HasChange ("daily_data_cap_notifications_disabled" ) {
631+ billingProps .DataVolumeCap .StopSendNotificationWhenHitCap = pointer .To (d .Get ("daily_data_cap_notifications_disabled" ).(bool ))
632+ }
532633 }
533634
534635 if _ , err = billingClient .ComponentCurrentBillingFeaturesUpdate (ctx , * billingId , * billingProps ); err != nil {
0 commit comments