Skip to content

Commit 5287714

Browse files
committed
Remove debug and timing logs from Add-CIPPAzDataTableEntity and Add-CIPPDbItem
Eliminated detailed timing and debug output from Add-CIPPAzDataTableEntity.ps1 to reduce log verbosity and improve performance. Commented out Write-Debug statements in Add-CIPPDbItem.ps1 and added property selection to Get-CIPPAzDataTableEntity for efficiency.
1 parent 9b7e995 commit 5287714

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

Modules/CIPPCore/Public/Add-CIPPAzDataTableEntity.ps1

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ function Add-CIPPAzDataTableEntity {
4040
$MaxRowSize = 500000 - 100
4141
$MaxSize = 30kb
4242

43-
$startTime = Get-Date
44-
$entityCount = @($Entity).Count
45-
$totalValidationTime = 0
46-
$totalAddTime = 0
47-
Write-Information "[Add-CIPPAzDataTableEntity] Processing $entityCount entities"
48-
4943
foreach ($SingleEnt in @($Entity)) {
5044
try {
5145
# Skip null entities
@@ -68,7 +62,6 @@ function Add-CIPPAzDataTableEntity {
6862
}
6963

7064
# Additional validation for AzBobbyTables compatibility
71-
$validationStart = Get-Date
7265
try {
7366
# Ensure all property values are not null for string properties
7467
if ($SingleEnt -is [hashtable]) {
@@ -91,15 +84,8 @@ function Add-CIPPAzDataTableEntity {
9184
} catch {
9285
Write-Warning "Error during entity validation: $($_.Exception.Message)"
9386
}
94-
$validationEnd = Get-Date
95-
$validationDuration = ($validationEnd - $validationStart).TotalMilliseconds
96-
$totalValidationTime += $validationDuration
9787

98-
$addStart = Get-Date
9988
Add-AzDataTableEntity @Parameters -Entity $SingleEnt -ErrorAction Stop
100-
$addEnd = Get-Date
101-
$addDuration = ($addEnd - $addStart).TotalMilliseconds
102-
$totalAddTime += $addDuration
10389

10490
} catch [System.Exception] {
10591
if ($_.Exception.ErrorCode -in @('PropertyValueTooLarge', 'EntityTooLarge', 'RequestBodyTooLarge')) {
@@ -251,10 +237,4 @@ function Add-CIPPAzDataTableEntity {
251237
}
252238
}
253239
}
254-
255-
$endTime = Get-Date
256-
$totalDuration = [math]::Round(($endTime - $startTime).TotalSeconds, 2)
257-
$avgValidation = [math]::Round($totalValidationTime / $entityCount, 2)
258-
$avgAdd = [math]::Round($totalAddTime / $entityCount, 2)
259-
Write-Debug "[Add-CIPPAzDataTableEntity] Completed $entityCount entities in ${totalDuration}s (avg validation: ${avgValidation}ms, avg add: ${avgAdd}ms)"
260240
}

Modules/CIPPCore/Public/Add-CIPPDbItem.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ function Add-CIPPDbItem {
9999
$MemoryAfterGC = [System.GC]::GetTotalMemory($false)
100100
$FreedMB = [math]::Round(($MemoryBeforeGC - $MemoryAfterGC) / 1MB, 2)
101101
$CurrentMemoryMB = [math]::Round($MemoryAfterGC / 1MB, 2)
102-
Write-Debug "Batch $($State.BatchNumber): ${flushDuration}s total (write: ${writeDuration}s, gc: ${gcDuration}s) | Processed: $($State.TotalProcessed) | Memory: ${CurrentMemoryMB}MB | Freed: ${FreedMB}MB"
102+
#Write-Debug "Batch $($State.BatchNumber): ${flushDuration}s total (write: ${writeDuration}s, gc: ${gcDuration}s) | Processed: $($State.TotalProcessed) | Memory: ${CurrentMemoryMB}MB | Freed: ${FreedMB}MB"
103103
}
104104
}
105105

106106
if (-not $Count.IsPresent) {
107107
# Delete existing entries for this type
108108
$Filter = "PartitionKey eq '{0}' and RowKey ge '{1}-' and RowKey lt '{1}0'" -f $TenantFilter, $Type
109-
$ExistingEntities = Get-CIPPAzDataTableEntity @Table -Filter $Filter
109+
$ExistingEntities = Get-CIPPAzDataTableEntity @Table -Filter $Filter -Property PartitionKey, RowKey, ETag
110110
if ($ExistingEntities) {
111111
Remove-AzDataTableEntity @Table -Entity $ExistingEntities -Force | Out-Null
112112
}
113113
$AllocatedMemoryMB = [math]::Round([System.GC]::GetTotalMemory($false) / 1MB, 2)
114-
Write-Debug "Starting $Type import for $TenantFilter | Allocated Memory: ${AllocatedMemoryMB}MB | Batch Size: 500"
114+
#Write-Debug "Starting $Type import for $TenantFilter | Allocated Memory: ${AllocatedMemoryMB}MB | Batch Size: 500"
115115
}
116116
}
117117

@@ -184,7 +184,7 @@ function Add-CIPPDbItem {
184184
Write-LogMessage -API 'CIPPDbItem' -tenant $TenantFilter `
185185
-message "Failed to add items of type $Type : $($_.Exception.Message)" -sev Error `
186186
-LogData (Get-CippException -Exception $_)
187-
Write-Debug "[Add-CIPPDbItem] $TenantFilter - $(Get-CippException -Exception $_ | ConvertTo-Json -Depth 5 -Compress)"
187+
#Write-Debug "[Add-CIPPDbItem] $TenantFilter - $(Get-CippException -Exception $_ | ConvertTo-Json -Depth 5 -Compress)"
188188
throw
189189
} finally {
190190
# Record count if AddCount was specified

0 commit comments

Comments
 (0)