Updating the PowerShell Module part 3 - improved User Friendlier Output #365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Phase 5: Intelligent Output Formatting System - PR Notes
Overview
This PR implements a comprehensive output formatting system for the MicrosoftFabricMgmt module, transforming raw API responses with GUIDs into user-friendly, human-readable output with automatic name resolution and intelligent caching.
🎯 Problem Statement
Before: Get-* cmdlets returned raw API responses with GUIDs that were difficult to read and interpret:
After: Formatted output with resolved names in consistent columns:
📊 What Was Changed
Core Infrastructure
1. Public Helper Functions (3 new exports)
Moved from Private to Public for format file accessibility:
Resolve-FabricCapacityName(source/Public/Utils/Resolve-FabricCapacityName.ps1)MicrosoftFabricMgmt.Cache.CapacityName_{CapacityId}Resolve-FabricWorkspaceName(source/Public/Utils/Resolve-FabricWorkspaceName.ps1)MicrosoftFabricMgmt.Cache.WorkspaceName_{WorkspaceId}Resolve-FabricCapacityIdFromWorkspace(source/Public/Utils/Resolve-FabricCapacityIdFromWorkspace.ps1)MicrosoftFabricMgmt.Cache.WorkspaceCapacityId_{WorkspaceId}2. Format File (source/MicrosoftFabricMgmt.Format.ps1xml)
Created comprehensive format file with 6 specialized views:
FabricItemView - Default view for 32 item types:
WorkspaceView - For workspace objects:
CapacityView - For capacity objects:
DomainView - For domain objects:
RoleAssignmentView - For workspace role assignments (NEW):
JobView - For job objects:
3. Enhanced Helper Functions
Add-FabricTypeName(source/Private/Add-FabricTypeName.ps1)Select-FabricResource(source/Private/Select-FabricResource.ps1)-TypeNameparameterFunctions Updated (11 total)
Already Formatted (from earlier phases):
Newly Formatted (Phase 5):
Module Manifest Changes (source/MicrosoftFabricMgmt.psd1)
Line 65: Added format file loading:
Lines 201-202: Exported 3 new public functions:
🚀 Key Features
Cascading Resolution
The Problem: Many Fabric items (Lakehouse, Notebook, Warehouse, etc.) only return
workspaceIdin their API response, notcapacityId. This made it impossible to display the capacity name directly.The Solution: Cascading resolution through workspace:
Implementation in format file (lines 66-80):
Intelligent Caching
Performance Impact:
CapacityName_{CapacityId}→ Display nameWorkspaceName_{WorkspaceId}→ Display nameWorkspaceCapacityId_{WorkspaceId}→ Capacity GUIDCache Management:
Format View Selection
PowerShell automatically selects the correct view based on PSTypeName:
📚 Documentation Created/Updated
New Documentation (5 files)
docs/Resolve-FabricCapacityName.md
docs/Resolve-FabricWorkspaceName.md
docs/Resolve-FabricCapacityIdFromWorkspace.md
PHASE6_FORMATTING_COMPLETION.md
docs/Clear-FabricNameCache.md (from earlier)
Updated Documentation
docs/OUTPUT-FORMATTING.md
output/ReleaseNotes.md
🔧 Technical Details
Format File Structure
Format files execute in module scope and need access to module functions. This is why helper functions were moved from Private to Public.
Key ScriptBlock Pattern:
Type Decoration Patterns
Pattern 1: Via Select-FabricResource (Preferred):
Pattern 2: Direct decoration:
Pattern 3: Custom objects (like RoleAssignments):
🧪 Testing
Manual Testing
Unit Tests
All existing unit tests pass. Helper functions have comprehensive test coverage:
tests/Unit/Public/Resolve-FabricCapacityName.Tests.ps1(8 tests)tests/Unit/Public/Resolve-FabricWorkspaceName.Tests.ps1(10 tests)tests/Unit/Public/Clear-FabricNameCache.Tests.ps1(10 tests)Note: Tests need to be moved from
Private/toPublic/subdirectory since functions are now public.Build Status
📈 Performance Metrics
Before (No Caching)
After (With Caching)
Real-World Impact
🎯 Coverage Status
Current Status (Phase 5)
Remaining Work (Phase 6)
🔍 Error Handling Review
As part of this phase, error handling in
Invoke-FabricAPIRequestwas reviewed and confirmed to be correct and complete:✅ Handles standard Fabric error format (
errorCode,message,requestId)✅ Handles nested error format (
error.code,error.message)✅ Provides meaningful HTTP status messages
✅ Implements retry logic for transient failures (429, 503, 504)
✅ Respects Retry-After headers
No changes needed.
🚨 Breaking Changes
None. This is purely additive:
$lakehouse.workspaceId📋 Migration Notes
No migration required. Users will automatically see formatted output when they update to 1.0.2.
To get raw object properties (if needed):
📦 Files Changed Summary
Added (12 files)
Modified (9 files)
Deleted (3 files)
✅ Review Checklist
Target:
mainVersion: 1.0.3
Date: 2026-01-14
Related Documentation: