diff --git a/internal/services/signalr/signalr_service_resource.go b/internal/services/signalr/signalr_service_resource.go index 73974078e709..3734ea7afa46 100644 --- a/internal/services/signalr/signalr_service_resource.go +++ b/internal/services/signalr/signalr_service_resource.go @@ -341,7 +341,9 @@ func resourceArmSignalRServiceUpdate(d *pluginsdk.ResourceData, meta interface{} currentSku = resourceType.Sku.Name } - if d.HasChanges("cors", "features", "upstream_endpoint", "connectivity_logs_enabled", "messaging_logs_enabled", "http_request_logs_enabled", "service_mode", "live_trace_enabled", "live_trace") { + if d.HasChanges("cors", "upstream_endpoint", "serverless_connection_timeout_in_seconds", "identity", + "public_network_access_enabled", "local_auth_enabled", "aad_auth_enabled", "tls_client_cert_enabled", + "features", "connectivity_logs_enabled", "messaging_logs_enabled", "http_request_logs_enabled", "service_mode", "live_trace_enabled", "live_trace") { resourceType.Properties = &signalr.SignalRProperties{} if d.HasChange("cors") { @@ -349,114 +351,97 @@ func resourceArmSignalRServiceUpdate(d *pluginsdk.ResourceData, meta interface{} resourceType.Properties.Cors = expandSignalRCors(corsRaw) } - if d.HasChange("live_trace") { - resourceType.Properties.LiveTraceConfiguration = expandSignalRLiveTraceConfig(d.Get("live_trace").([]interface{})) + if d.HasChange("upstream_endpoint") { + featuresRaw := d.Get("upstream_endpoint").(*pluginsdk.Set).List() + resourceType.Properties.Upstream = expandUpstreamSettings(featuresRaw) } - if d.HasChanges("connectivity_logs_enabled", "messaging_logs_enabled", "service_mode", "live_trace_enabled", "http_request_logs_enabled") { - if d.HasChange("public_network_access_enabled") { - publicNetworkAcc := "Enabled" - if !d.Get("public_network_access_enabled").(bool) { - publicNetworkAcc = "Disabled" - } - if currentSku == "Free_F1" && publicNetworkAcc == "Disabled" { - return fmt.Errorf("SKU Free_F1 does not support disabling public network access") - } - resourceType.Properties.PublicNetworkAccess = utils.String(publicNetworkAcc) + if d.HasChange("serverless_connection_timeout_in_seconds") { + resourceType.Properties.Serverless = &signalr.ServerlessSettings{ + ConnectionTimeoutInSeconds: utils.Int64(int64(d.Get("serverless_connection_timeout_in_seconds").(int))), } + } - if d.HasChange("local_auth_enabled") { - resourceType.Properties.DisableLocalAuth = utils.Bool(!d.Get("local_auth_enabled").(bool)) + if d.HasChange("identity") { + identity, err := identity.ExpandSystemOrUserAssignedMap(d.Get("identity").([]interface{})) + if err != nil { + return fmt.Errorf("expanding `identity`: %+v", err) } + resourceType.Identity = identity + } - if d.HasChange("aad_auth_enabled") { - resourceType.Properties.DisableAadAuth = utils.Bool(!d.Get("aad_auth_enabled").(bool)) + if d.HasChange("public_network_access_enabled") { + publicNetworkAcc := "Enabled" + if !d.Get("public_network_access_enabled").(bool) { + publicNetworkAcc = "Disabled" } - - if d.HasChange("tls_client_cert_enabled") { - tlsClientCertEnabled := d.Get("tls_client_cert_enabled").(bool) - resourceType.Properties.Tls = &signalr.SignalRTlsSettings{ - ClientCertEnabled: utils.Bool(tlsClientCertEnabled), - } - if currentSku == "Free_F1" && tlsClientCertEnabled { - return fmt.Errorf("SKU Free_F1 does not support enabling tls client cert") - } + if currentSku == "Free_F1" && publicNetworkAcc == "Disabled" { + return fmt.Errorf("SKU Free_F1 does not support disabling public network access") } + resourceType.Properties.PublicNetworkAccess = utils.String(publicNetworkAcc) + } - if d.HasChange("serverless_connection_timeout_in_seconds") { - resourceType.Properties.Serverless = &signalr.ServerlessSettings{ - ConnectionTimeoutInSeconds: utils.Int64(int64(d.Get("serverless_connection_timeout_in_seconds").(int))), - } - } + if d.HasChange("local_auth_enabled") { + resourceType.Properties.DisableLocalAuth = utils.Bool(!d.Get("local_auth_enabled").(bool)) + } - if d.HasChange("identity") { - identity, err := identity.ExpandSystemOrUserAssignedMap(d.Get("identity").([]interface{})) - if err != nil { - return fmt.Errorf("expanding `identity`: %+v", err) - } - resourceType.Identity = identity + if d.HasChange("aad_auth_enabled") { + resourceType.Properties.DisableAadAuth = utils.Bool(!d.Get("aad_auth_enabled").(bool)) + } + + if d.HasChange("tls_client_cert_enabled") { + tlsClientCertEnabled := d.Get("tls_client_cert_enabled").(bool) + resourceType.Properties.Tls = &signalr.SignalRTlsSettings{ + ClientCertEnabled: utils.Bool(tlsClientCertEnabled), } + if currentSku == "Free_F1" && tlsClientCertEnabled { + return fmt.Errorf("SKU Free_F1 does not support enabling tls client cert") + } + } - if d.HasChanges("connectivity_logs_enabled", "messaging_logs_enabled", "service_mode", "live_trace_enabled", "http_request_logs_enabled") { - features := make([]signalr.SignalRFeature, 0) - logChanged := false - var connectivityLogsEnabled, messagingLogsEnabled, httpLogsEnabled bool - if d.HasChange("connectivity_logs_enabled") { - if v, ok := d.GetOk("connectivity_logs_enabled"); ok { - connectivityLogsEnabled = v.(bool) - } - features = append(features, signalRFeature(signalr.FeatureFlagsEnableConnectivityLogs, strconv.FormatBool(connectivityLogsEnabled))) - logChanged = true - } + if d.HasChanges("connectivity_logs_enabled", "messaging_logs_enabled", "http_request_logs_enabled", "live_trace_enabled", "service_mode") { + features := make([]signalr.SignalRFeature, 0) + if d.HasChange("connectivity_logs_enabled") || d.HasChange("messaging_logs_enabled") || d.HasChange("http_request_logs_enabled") { + connectivityLogsNew := d.Get("connectivity_logs_enabled") + features = append(features, signalRFeature(signalr.FeatureFlagsEnableConnectivityLogs, strconv.FormatBool(connectivityLogsNew.(bool)))) - if d.HasChange("messaging_logs_enabled") { - if v, ok := d.GetOk("messaging_logs_enabled"); ok { - messagingLogsEnabled = v.(bool) - } - features = append(features, signalRFeature(signalr.FeatureFlagsEnableMessagingLogs, strconv.FormatBool(messagingLogsEnabled))) - logChanged = true - } + messagingLogsNew := d.Get("messaging_logs_enabled") + features = append(features, signalRFeature(signalr.FeatureFlagsEnableMessagingLogs, strconv.FormatBool(messagingLogsNew.(bool)))) - if d.HasChange("http_request_logs_enabled") { - if v, ok := d.GetOk("http_request_logs_enabled"); ok { - httpLogsEnabled = v.(bool) - } - logChanged = true - } + httpLogsNew := d.Get("http_request_logs_enabled") - if logChanged { - resourceType.Properties.ResourceLogConfiguration = expandSignalRResourceLogConfig(connectivityLogsEnabled, messagingLogsEnabled, httpLogsEnabled) - } + resourceType.Properties.ResourceLogConfiguration = expandSignalRResourceLogConfig(connectivityLogsNew.(bool), messagingLogsNew.(bool), httpLogsNew.(bool)) + } - if d.HasChange("live_trace_enabled") { - liveTraceEnabled := false - if v, ok := d.GetOk("live_trace_enabled"); ok { - liveTraceEnabled = v.(bool) - } - features = append(features, signalRFeature("EnableLiveTrace", strconv.FormatBool(liveTraceEnabled))) + if d.HasChange("live_trace_enabled") { + liveTraceEnabled := false + if v, ok := d.GetOk("live_trace_enabled"); ok { + liveTraceEnabled = v.(bool) } + features = append(features, signalRFeature("EnableLiveTrace", strconv.FormatBool(liveTraceEnabled))) + } - if d.HasChange("service_mode") { - serviceMode := "Default" - if v, ok := d.GetOk("service_mode"); ok { - serviceMode = v.(string) - } - features = append(features, signalRFeature(signalr.FeatureFlagsServiceMode, serviceMode)) + if d.HasChange("service_mode") { + serviceMode := "Default" + if v, ok := d.GetOk("service_mode"); ok { + serviceMode = v.(string) } - resourceType.Properties.Features = &features + features = append(features, signalRFeature(signalr.FeatureFlagsServiceMode, serviceMode)) } - if d.HasChange("upstream_endpoint") { - featuresRaw := d.Get("upstream_endpoint").(*pluginsdk.Set).List() - resourceType.Properties.Upstream = expandUpstreamSettings(featuresRaw) - } + resourceType.Properties.Features = &features } - if d.HasChange("tags") { - tagsRaw := d.Get("tags").(map[string]interface{}) - resourceType.Tags = tags.Expand(tagsRaw) + if d.HasChange("live_trace") { + resourceType.Properties.LiveTraceConfiguration = expandSignalRLiveTraceConfig(d.Get("live_trace").([]interface{})) } } + + if d.HasChange("tags") { + tagsRaw := d.Get("tags").(map[string]interface{}) + resourceType.Tags = tags.Expand(tagsRaw) + } + if err := client.UpdateThenPoll(ctx, *id, resourceType); err != nil { return fmt.Errorf("updating %s: %+v", *id, err) }