-
Notifications
You must be signed in to change notification settings - Fork 195
How do I find my Azure Tenant ID
Ian Hellen edited this page Nov 8, 2021
·
1 revision
Enter the code below into a notebook and run to retrieve the Tenant ID for your Microsoft Sentinel workspace.
You can find the subscription (my_sub_uuid
parameter in the code) of the Sentinel workspace in the Workspace properties tab.
Replace the value my_sub_uuid
with the UUID of your subscription (must be a quoted string), before running the cell.
import requests
def get_tenant_for_subscription(sub_id):
aad_url = (
f"https://management.azure.com/subscriptions/{sub_id}?api-version=2016-01-01"
)
resp = requests.get(aad_url)
if resp.status_code == 401:
hdr_list = resp.headers["WWW-Authenticate"].split(",")
hdr_dict = {
item.split("=")[0].strip(): item.split("=")[1].strip() for item in hdr_list
}
return hdr_dict["Bearer authorization_uri"].strip('"').split("/")[3]
else:
return None
get_tenant_for_subscription("my_sub_uuid")