Last active
September 2, 2021 17:23
-
-
Save jonuwz/b0576257d7dd99d094bbd773433c1bde to your computer and use it in GitHub Desktop.
list subs if service principal has been added to > 1 sub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install azure-mgmt-resource azure-identity | |
import os | |
import json | |
from azure.mgmt.resource import SubscriptionClient | |
from azure.identity import ClientSecretCredential | |
active_dict= {} | |
t_id = '' | |
username = '' | |
password = '' | |
credential = ClientSecretCredential(tenant_id=t_id, client_id=username, client_secret=password) | |
subscription_client = SubscriptionClient(credential) | |
for subscription in subscription_client.subscriptions.list(): | |
if subscription.state == "Enabled": | |
print(subscription) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment