Azure DNS-bibliotek för Python
Översikt
Azure DNS är en värdtjänst för DNS-domäner som tillhandahåller DNS-matchning via Azure-infrastrukturen.
Information om hur du kommer igång med Azure DNS finns i Kom igång med Azure DNS med hjälp av Azure Portal.
Hanterings-API
pip install azure-mgmt-dns
Skapa hanteringsklienten
Följande kod skapar en instans av hanteringsklienten.
Du måste ange vilken subscription_id
som kan hämtas från din prenumerationslista.
Mer information om hur du hanterar Azure Active Directory-autentisering med Python SDK och hur du skapar en Credentials
instans finns i Autentisering för resurshantering.
from azure.mgmt.dns import DnsManagementClient
from azure.common.credentials import UserPassCredentials
# Replace this with your subscription id
subscription_id = '33333333-3333-3333-3333-333333333333'
# See above for details on creating different types of AAD credentials
credentials = UserPassCredentials(
'user@domain.com', # Your user
'my_password', # Your password
)
dns_client = DnsManagementClient(
credentials,
subscription_id
)
Skapa DNS-zon
# The only valid value is 'global', otherwise you will get a:
# The subscription is not registered for the resource type 'dnszones' in the location 'westus'.
zone = dns_client.zones.create_or_update(
'MyResourceGroup',
'pydns.com',
{
'zone_type': 'Public', # or Private
'location': 'global'
}
)
Skapa en postuppsättning
record_set = dns_client.record_sets.create_or_update(
'MyResourceGroup',
'pydns.com',
'MyRecordSet',
'A',
{
"ttl": 300,
"arecords": [
{
"ipv4_address": "1.2.3.4"
},
{
"ipv4_address": "1.2.3.5"
}
]
}
)
Azure SDK for Python
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: Under hela 2024 kommer vi att fasa ut GitHub-problem som feedbackmekanism för innehåll och ersätta det med ett nytt feedbacksystem. Mer information finns i:Skicka och visa feedback för