Check for ScheduledPurgeDate before logging in Resource Helper Script#15475
Check for ScheduledPurgeDate before logging in Resource Helper Script#15475
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the common resource cleanup helper (Remove-PurgeableResources) to avoid failures when deleted Key Vault / Managed HSM objects don’t expose ScheduledPurgeDate, while still emitting useful verbose logging about which resource is being skipped due to purge protection.
Changes:
- Build the purge-protection verbose message in two steps (resource name + optional purge date suffix).
- Guard access to
ScheduledPurgeDateby checking the property exists and is non-empty before logging it. - Apply the same handling for both Key Vault and Managed HSM resource types.
Show a summary per file
| File | Description |
|---|---|
| eng/common/scripts/Helpers/Resource-Helpers.ps1 | Makes purge-protection verbose logging resilient to missing ScheduledPurgeDate while preserving resource identification in logs. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
|
The following pipelines have been queued for testing: |
|
The following pipelines have been queued for testing: |
Currently clean up script is failing in scenario where are a resource doesn't have a "ScheduledPurgeDate". Current logging doesn't allow us to even see the name of said resource. This change updates logging so resource name is logged separately before scheduledpurgedate, and such situation where there is no purge date is handled