Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit 0a5a1c8

Browse files
authored
Update api.py
Patch to handle dead subscriptions
1 parent 1004d70 commit 0a5a1c8

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

siem_query_utils/api.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,22 @@ def workspace_details():
200200
for wsdata in list_workspaces("json"):
201201
customerId = wsdata["customerId"]
202202
sub = wsdata["subscription"]
203-
ws = azcli(
204-
[
205-
"monitor",
206-
"log-analytics",
207-
"workspace",
208-
"list",
209-
"--subscription",
210-
sub,
211-
"--query",
212-
f"[?customerId == '{customerId}']",
213-
]
214-
)[0]
203+
try: # handle dead/missing subscriptions
204+
ws = azcli(
205+
[
206+
"monitor",
207+
"log-analytics",
208+
"workspace",
209+
"list",
210+
"--subscription",
211+
sub,
212+
"--query",
213+
f"[?customerId == '{customerId}']",
214+
]
215+
)[0]
216+
except Exception as exc:
217+
logger.warning(exc)
218+
continue
215219
ws["id"] = ws["id"].lower()
216220
ws["name"] = ws["name"].lower()
217221
ws["ingest_function"] = f"{ws['customerId'].replace('-', '_')}_incoming"

0 commit comments

Comments
 (0)