diff --git a/internal/services/loganalytics/log_analytics_workspace_table_resource.go b/internal/services/loganalytics/log_analytics_workspace_table_resource.go index 0760259e69040..433926792f9d3 100644 --- a/internal/services/loganalytics/log_analytics_workspace_table_resource.go +++ b/internal/services/loganalytics/log_analytics_workspace_table_resource.go @@ -133,8 +133,12 @@ func (r LogAnalyticsWorkspaceTableResource) Create() sdk.ResourceFunc { if model.Plan == string(tables.TablePlanEnumAnalytics) { updateInput.Properties.RetentionInDays = pointer.To(model.RetentionInDays) + } + + if model.TotalRetentionInDays != 0 { updateInput.Properties.TotalRetentionInDays = pointer.To(model.TotalRetentionInDays) } + if err := client.CreateOrUpdateThenPoll(ctx, id, updateInput); err != nil { return fmt.Errorf("failed to update table %s in workspace %s in resource group %s: %s", tableName, workspaceId.WorkspaceName, workspaceId.ResourceGroupName, err) } diff --git a/internal/services/loganalytics/log_analytics_workspace_table_resource_test.go b/internal/services/loganalytics/log_analytics_workspace_table_resource_test.go index 5db39e331c878..9e6adf3b2cf49 100644 --- a/internal/services/loganalytics/log_analytics_workspace_table_resource_test.go +++ b/internal/services/loganalytics/log_analytics_workspace_table_resource_test.go @@ -104,9 +104,10 @@ resource "azurerm_log_analytics_workspace" "test" { retention_in_days = 30 } resource "azurerm_log_analytics_workspace_table" "test" { - name = "AppTraces" - workspace_id = azurerm_log_analytics_workspace.test.id - plan = "Basic" + name = "AppTraces" + workspace_id = azurerm_log_analytics_workspace.test.id + plan = "Basic" + total_retention_in_days = 32 } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) }