How ch1nch4ch4/az-endpoint-discovery works
Project type and purpose
• This is an open-source, modular PowerShell CLI tool whose sole responsibility is to discover and report on internet-exposed Azure endpoints across one or many subscriptions/tenants.
• It connects to Azure via PowerShell, iterates subscriptions, invokes a set of discovery modules (one per Azure service or resource category), aggregates the results, and writes a Markdown and CSV report.
Main components
a. CLI Entry Point (Get-AzureEndpointDiscovery.ps1)
• Orchestrates the run: parses parameters, bootstraps module loader, iterates subscriptions, invokes discovery modules, and hands off to the report generator.
b. Module Loader / Manager
• Dynamically imports / installs required Azure PowerShell Az.* modules and our custom .psm1 files from the Modules/ directory.
• Provides a plugin boundary for each resource-type discovery function.
c. Discovery Modules (one per .psm1 under Modules/)
• VirtualMachines.psm1, WebApps.psm1, StorageAccounts.psm1, etc.
• Each exposes a standardized function (e.g., Get-XyzEndpoints) returning objects with ResourceName, Endpoint, Type, SubscriptionId, ResourceGroup.
d. Azure Control Plane
• The underlying Az PowerShell modules talk to Azure Resource Manager (ARM) REST APIs or Resource Graph.
e. Aggregation & Reporting Engine
• Takes module outputs, groups by subscription and resource type, formats into Markdown and CSV.
• Writes files under the selected OutputPath (default: current directory), under Reports/.
f. File System / Reports Store
• Directory structure under Reports/, including example CSV/MD, and per-tenant subdirectories.
g. User / Operator
• Launches the script, supplies optional parameters (SubscriptionIds, TenantId, SkipResourceTypes, OutputPath).
Relationships and data flow
• User → CLI Entry Point
• CLI Entry Point → Module Loader
• Module Loader → Discovery Modules (loops over each .psm1)
• Discovery Modules → Azure Control Plane (API calls)
• Azure Control Plane → Discovery Modules (returns resource data)
• Discovery Modules → Aggregation & Reporting Engine (raw findings)
• Reporting Engine → File System (Markdown + CSV files under Reports/)
• User → Views Reports
Architectural patterns & design principles
• Plugin/Module Pattern: Each resource type is a self-contained PowerShell module. Adding a new resource involves dropping a new .psm1 in Modules/.
• Single Responsibility: Entry point only orchestrates; modules only discover; reporting engine only formats.
• Dependency Injection (implicit): Modules assume a standard input/output contract, injected by the orchestrator.
• Separation of Concerns: Clear divide between discovery, Azure interactions, and reporting.
• Components listed above.
• Plugin architecture and reporting pipeline are both obvious.
• Don’t overcrowd: cluster similar modules together but call out the loader’s discovery loop.