Add dns-config module for Mail-in-a-Box DNS management and Azure integration
This commit is contained in:
15
dns-config/azure.py
Normal file
15
dns-config/azure.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.mgmt.dns import DnsManagementClient
|
||||
import os
|
||||
|
||||
AZURE_SUBSCRIPTION_ID = os.environ.get("AZURE_SUBSCRIPTION_ID", None)
|
||||
|
||||
def get_dns_nameservers(resource_group_name: str, zone_name: str, azure_subscription_id: str | None = None) -> list[str]:
|
||||
try:
|
||||
creds = DefaultAzureCredential()
|
||||
dns_client = DnsManagementClient(creds, azure_subscription_id or AZURE_SUBSCRIPTION_ID)
|
||||
zone = dns_client.zones.get(resource_group_name, zone_name)
|
||||
return zone.name_servers
|
||||
except Exception as e:
|
||||
print(f"Error fetching DNS nameservers: {e}")
|
||||
return []
|
||||
Reference in New Issue
Block a user