Skip to content

Commit 8cace7d

Browse files
push
1 parent e9c6463 commit 8cace7d

File tree

6 files changed

+622
-417
lines changed

6 files changed

+622
-417
lines changed

Pipfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ argparse = "=1.4.0"
99
python-dotenv = "=1.0.1"
1010
azure-mgmt-authorization = "=4.0.0"
1111
azure-mgmt-resource = "=23.0.1"
12-
12+
azure-cli-core = "*"
13+
requests = "*"
1314

1415
[requires]
15-
python_version = "3"
16+
python_version = "3"

Pipfile.lock

Lines changed: 0 additions & 406 deletions
This file was deleted.

azcli.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
3+
"""
4+
# PREREQUISITES
5+
pip install azure-identity
6+
pip install azure-mgmt-authorization
7+
# USAGE
8+
python role_assignments_list_for_subscription.py
9+
10+
Before run the sample, please set the values of the client ID, tenant ID and client secret
11+
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
12+
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
13+
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
14+
"""
15+
16+
17+
def main():
18+
client = AuthorizationManagementClient(
19+
credential=DefaultAzureCredential(),
20+
subscription_id="e71149ae-05d3-4dcf-b946-d71f3f3cae89",
21+
)
22+
23+
response = client.role_assignments.list_for_subscription()
24+
for item in response:
25+
print(item)
26+
27+
28+
# x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_ListForSubscription.json
29+
if __name__ == "__main__":
30+
main()

0 commit comments

Comments
 (0)