Tips for monitoring memory consumption of an Azure function (or other) dll

To to monitor memory footprint for the dotnet.exe instance running ParquetImporter.dll, use PowerShell to filter on the command line.

Context: Windows Powershell, Visual Studio 2026 (Running locally in .NET development context)

Find the process

Get-CimInstance Win32_Process |
Where-Object { $_.Name -eq 'dotnet.exe' -and $_.CommandLine -match 'ParquetImporter\.dll' } |
Select-Object ProcessId, CommandLine

Show current and peak memory

Get-CimInstance Win32_Process |
Where-Object { $_.Name -eq 'dotnet.exe' -and $_.CommandLine -match 'ParquetImporter\.dll' } |
ForEach-Object {
Get-Process -Id $_.ProcessId |
Select-Object Id,
@{N='CurrentMB';E={[math]::Round($_.WorkingSet64/1MB,1)}},
@{N='PeakMB';E={[math]::Round($_.PeakWorkingSet64/1MB,1)}}
}

Continuously watch memory and track the maximum

$max = 0
while ($true) {
$pid = (Get-CimInstance Win32_Process |
Where-Object {
$_.Name -eq 'dotnet.exe' -and
$_.CommandLine -match 'ParquetImporter\.dll'
}).ProcessId
if ($pid) {
$p = Get-Process -Id $pid
$current = [math]::Round($p.WorkingSet64 / 1MB, 1)
$peak = [math]::Round($p.PeakWorkingSet64 / 1MB, 1)
if ($current -gt $max) { $max = $current }
Clear-Host
Write-Host "PID: $pid"
Write-Host "Current: $current MB"
Write-Host "Peak (Windows): $peak MB"
Write-Host "Max observed by script: $max MB"
}
Start-Sleep -Seconds 1
}

 

Can I get detailed exception stacktrace in PowerShell? – Stack Overflow

There is a function up on the PowerShell Team blog called Resolve-Error which will get you all kinds of detailsNote that $error is an array of all the errors you have encountered in your PSSession. This function will give you details on the last error you encountered.

function Resolve-Error ($ErrorRecord=$Error[0])
{
$ErrorRecord | Format-List * -Force
$ErrorRecord.InvocationInfo |Format-List *
$Exception = $ErrorRecord.Exception
for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException))
{ "$i" * 80
$Exception |Format-List * -Force
}
}

Source: Can I get detailed exception stacktrace in PowerShell? – Stack Overflow

Powershell Generic Invoke-RestMethod / WebRequest error handler

From: https://stackoverflow.com/questions/39319680/onelogin-rest-api-with-powershells-invoke-restmethod

#generic Invoke-RestMethod / WebRequest error handler
#https://stackoverflow.com/questions/39319680/onelogin-rest-api-with-powershells-invoke-restmethod
function Failure {
$global:helpme = $body
$global:helpmoref = $moref
$global:result = $_.Exception.Response.GetResponseStream()
$global:reader = New-Object System.IO.StreamReader($global:result)
$global:responseBody = $global:reader.ReadToEnd();
Write-Host -BackgroundColor:Black -ForegroundColor:Red "Status: A system exception was caught."
Write-Host -BackgroundColor:Black -ForegroundColor:Red $global:responsebody
Write-Host -BackgroundColor:Black -ForegroundColor:Red "The request body has been saved to `$global:helpme"
break
}

Then, wrap all of your Invoke-RestMethod calls in a try Catch block like this.

try { 
  $e = Invoke-WebRequest 'https://api.us.onelogin.com/api/1/users/$id' `
     -Headers  @{ Authorization = "bearer:$token" } `
     -Body  ( @{ phone = "7709746046" } | ConvertTo-Json ) `
     -Method Put -ErrorAction:Stop -ContentType 'application/json' 
     } 
catch {Failure}

Now when you run into an error, you can see the actual message, like this

> Status: A system exception was caught.
{"status":{"error":true,"code":400,"type":"bad request","message":{"description":"notes is not a valid attribute for user model","attribute":"notes"}}}
The request body has been saved to $global:helpme

Windows PowerShell concatenate and escape multi-line string

$x = @"
"Curiouser and curiouser!" cried Alice (she was so much surprised, that for the moment she quite forgot how to speak good English); "now I'm opening out like the largest telescope that ever was! Good-bye, feet!"
"@
$x

Source: Windows PowerShell Tip: Using Windows PowerShell “Here-Strings”