Skip to content

Commit 93d1cec

Browse files
committed
Fix Azure authentication issues and improve error handling
- Add PYTHONIOENCODING=utf-8 to main.py for Windows subprocess encoding - Update azure-identity to include broker extras for VS Code auth - Log failed subscriptions to separate file for better tracking
1 parent 8bcc59b commit 93d1cec

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

azure_discovery/discover.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,19 @@ def should_save_checkpoint():
317317

318318
print(f"\nTotal Native Objects found across all subscriptions: " f"{len(all_native_objects)}")
319319

320+
# Log failed subscriptions to a separate file
321+
if errors:
322+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
323+
error_file = f"output/azure_failed_subscriptions_{timestamp}.txt"
324+
try:
325+
os.makedirs("output", exist_ok=True)
326+
with open(error_file, 'w') as f:
327+
for error in errors:
328+
f.write(error + '\n')
329+
print(f"Failed subscriptions logged to: {error_file}")
330+
except Exception as e:
331+
print(f"Warning: Failed to write error log: {e}")
332+
320333
# Create a dummy discovery for counting and saving
321334
config = AzureConfig(
322335
regions=all_regions,

azure_discovery/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ azure-mgmt-resource>=23.0.0
44
azure-mgmt-dns>=8.0.0
55
azure-mgmt-privatedns>=1.0.0
66
azure-mgmt-subscription>=3.0.0
7-
azure-identity>=1.12.0
7+
azure-identity[broker]>=1.12.0
88
tqdm>=4.64.0
99
pandas>=1.5.0

main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# Add current directory to path for imports
1414
sys.path.insert(0, str(Path(__file__).parent))
1515

16+
# Set UTF-8 encoding for subprocess calls (fixes Windows encoding issues)
17+
os.environ['PYTHONIOENCODING'] = 'utf-8'
18+
1619

1720
def _print_kv(key: str, value: str) -> None:
1821
print(f" {key}: {value}")

0 commit comments

Comments
 (0)