A Python Package to List Azure Resources for Different Azure Services!
Project description
azurestapi
A Python Package to List Azure Resources for Different Azure Services!
Installation
Use the package manager pip to install akashjeez.
pip install azurestapi
Usage
from azurestapi import AzuRestAPI
from datetime import datetime, timedelta
## Below Start & End Date is used for Metrics for Azure Servies Such as VM's CPU Percentage, App Service's Requests Count etc.
start_date = (datetime.now() - timedelta(days = 30)).strftime('%Y-%m-%d')
end_date = datetime.now().strftime('%Y-%m-%d')
## Returns List of Attributes and Methods of this Package / Module.
print( dir( AzuRestAPI ) )
## Get the Token from https://docs.microsoft.com/en-us/rest/api/azure/
## Refer MSAL from https://docs.microsoft.com/en-us/azure/active-directory/develop/migrate-python-adal-msal
azure_object = AzuRestAPI( token = token )
## List All Azure Subscriptions for Logged in Account.
subscriptions = azure_object.List_Azure_Subscriptions()
subscriptions = azure_object.List_Azure_Subscriptions()['data']
print( subscriptions )
## For Dev/Tesing Subscription, Pass the Subscription ID and Name in Below Subscription.
subscriptions = [ {'subscription_id': '', 'subscription_name': ''} ]
## List Resource Groups and Resources under Resource Groups Across All Subscritions.
print( azure_object.List_Azure_Resource_Groups( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Resources( subscriptions = subscriptions ) )
## Azure Compute -> Virtual Machines, Disks, Snapshots Across All Subscritions.
print( azure_object.List_Azure_Virtual_Machines( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Disks( subscriptions = subscriptions) )
print( azure_object.List_Azure_Snapshots( subscriptions = subscriptions) )
## List Azure Advisor Recommendations Across All Subscritions.
print( azure_object.List_Azure_Advisor_Recommendations( subscriptions = subscriptions ) )
## List Azure Containerization Across All Subscritions.
print( azure_object.List_Azure_Container_Registries( subscriptions = subscriptions ) )
## Azure Storage & Backups Across All Subscritions.
print( azure_object.List_Azure_Storage_Accounts( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Recovery_Service_Vaults( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Recovery_Service_Vault_Backups( subscriptions = subscriptions ) )
## Azure Classic Virtual Machines, Storage Accounts, Disks etc.
print( azure_object.List_Azure_Classic_Virtual_Machines( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Classic_Storage_Accounts( subscriptions = subscriptions ) )
print( azure_object.Get_Classic_VM_CPU_Utilization( subscriptions = subscriptions,
start_date = start_date, end_date = end_date ) )
## Azure PaaS -> Web App Servies, App Service Plans.
print( azure_object.List_Azure_App_Services( subscriptions = subscriptions ) )
print( azure_object.List_Azure_App_Service_Plans( subscriptions = subscriptions ) )
## Azure Databases -> SQL Databases, SQL Managed Instances, SQL VM.
print( azure_object.List_Azure_SQL_Virtual_Machines( subscriptions = subscriptions ) )
print( azure_object.List_Azure_SQL_Databases( subscriptions = subscriptions ) )
print( azure_object.List_Azure_SQL_Elastic_Pools( subscriptions = subscriptions ) )
print( azure_object.List_Azure_SQL_Managed_Instances( subscriptions ) )
## Azure Networking
print( azure_object.List_Azure_Public_IP_Addresses( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Virtual_Networks( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Network_Security_Groups( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Load_Balancers( subscriptions = subscriptions ) )
print( azure_object.List_Azure_CDN_Profiles( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Application_Gateways( subscriptions = subscriptions ) )
## Azure Metrics, Monitor, and Activity Logs.
resource_id = '/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.Web/sites/APP_SERVICE_NAME'
subscription_id = resource_id.split('/')[2]
print( azure_object.List_Azure_Resource_Type_Metrics( resource_id = resource_id ) )
print( azure_object.List_Azure_Activity_Logs( subscription_id = subscription_id,
filter_query = f"eventTimestamp ge '{start_date}' and eventTimestamp le '{end_date}'" ) )
print( azure_object.Get_Azure_Resource_Metrics( resource_id = resource_id, metric_name = 'Requests',
timespan = f'{start_date}/{end_date}', interval = 'PT12H' ) )
print( azure_object.List_Azure_Log_Analytics_Workspaces( subscriptions = subscriptions ) )
print( azure_object.List_Azure_Application_Insights( subscriptions = subscriptions ) )
## Azure - AI/ML
print( azure_object.List_Azure_Cognitive_Service_Accounts( subscriptions = subscriptions ) )
## Azure Security Center
print( azure_object.List_Azure_Security_Center_Alerts( subscriptions = subscriptions ) )
Contributing
Pull Requests are Welcome. For Major Changes, Please Open an issue First to Discuss What You Would like to Change.
Please Make Sure to Update Tests as Appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
azurestapi-0.0.1.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file azurestapi-0.0.1.tar.gz
.
File metadata
- Download URL: azurestapi-0.0.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70fee44c47d818f52aea5e58a3abf4a55332a6fde690972dc2391f9de8c6ab1d |
|
MD5 | be1aed2ea44a8f25d07d1abe4bd09825 |
|
BLAKE2b-256 | a7b6b4c50b282b1396c3c49dd9aad754cdbc51a32859368c88f44185829d2c5b |
File details
Details for the file azurestapi-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: azurestapi-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b0120ca12927be3afa72411a87072e362b4972c83bc9931ac889d43824ef948 |
|
MD5 | d3758f4a09e45fa1975c87fe86dbd565 |
|
BLAKE2b-256 | 38aa742f523a15d3eb1c069a1252c2765f7a2bcdfa8b54c9608617b80a63f6e8 |