15
15
from azure .mgmt .privatedns .models import SubResource
16
16
from azure .mgmt .privatedns .models import VirtualNetworkLink
17
17
from ._client_factory import resource_client_factory , private_dns_client_factory , private_dns_link_client_factory
18
+ from ._config_reader import get_cloud_cluster
18
19
from ._flexible_server_util import get_id_components , check_existence , _is_resource_name , parse_public_access_input , get_user_confirmation , _check_resource_group_existence
19
20
from .validators import validate_private_dns_zone , validate_vnet_location
20
21
@@ -338,14 +339,6 @@ def prepare_mysql_exist_private_dns_zone(cmd, resource_group, private_dns_zone,
338
339
339
340
def prepare_private_dns_zone (db_context , resource_group , server_name , private_dns_zone , subnet_id , location , yes ):
340
341
cmd = db_context .cmd
341
- dns_suffix_client = db_context .cf_private_dns_zone_suffix (cmd .cli_ctx , '_' )
342
- private_dns_zone_suffix = dns_suffix_client .execute ()
343
- if db_context .command_group == 'mysql' :
344
- private_dns_zone_suffix = private_dns_zone_suffix .private_dns_zone_suffix
345
-
346
- # suffix should start with .
347
- if private_dns_zone_suffix [0 ] != '.' :
348
- private_dns_zone_suffix = '.' + private_dns_zone_suffix
349
342
350
343
# Get Vnet Components
351
344
vnet_subscription , vnet_rg , vnet_name , _ = get_id_components (subnet_id )
@@ -360,6 +353,20 @@ def prepare_private_dns_zone(db_context, resource_group, server_name, private_dn
360
353
"resource_group" : vnet_rg
361
354
})
362
355
356
+ cluster = get_cloud_cluster (cmd , location .replace ('/ +/g' , '' ).lower (), vnet_subscription )
357
+
358
+ if cluster is not None :
359
+ private_dns_zone_suffix = cluster ["privateDnsZoneDomain" ]
360
+ else :
361
+ dns_suffix_client = db_context .cf_private_dns_zone_suffix (cmd .cli_ctx , '_' )
362
+ private_dns_zone_suffix = dns_suffix_client .execute ()
363
+ if db_context .command_group == 'mysql' :
364
+ private_dns_zone_suffix = private_dns_zone_suffix .private_dns_zone_suffix
365
+
366
+ # suffix should start with .
367
+ if private_dns_zone_suffix [0 ] != '.' :
368
+ private_dns_zone_suffix = '.' + private_dns_zone_suffix
369
+
363
370
# Process private dns zone (no input or Id input)
364
371
dns_rg = None
365
372
dns_subscription = vnet_subscription
0 commit comments