From 373e887e7ff4266b7b5e40f3cffae405e70a8717 Mon Sep 17 00:00:00 2001 From: MyronFanQiu <49134743+MyronFanQiu@users.noreply.github.com> Date: Mon, 29 Jul 2019 17:13:56 +0800 Subject: [PATCH] a bug fix for elastic pool name (#56820) --- .../modules/cloud/azure/azure_rm_sqldatabase.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/azure/azure_rm_sqldatabase.py b/lib/ansible/modules/cloud/azure/azure_rm_sqldatabase.py index 418aec6def7..3dfcf1b9049 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_sqldatabase.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_sqldatabase.py @@ -196,7 +196,7 @@ status: ''' import time -from ansible.module_utils.azure_rm_common import AzureRMModuleBase +from ansible.module_utils.azure_rm_common import AzureRMModuleBase, format_resource_id try: from msrestazure.azure_exceptions import CloudError @@ -339,7 +339,7 @@ class AzureRMSqlDatabase(AzureRMModuleBase): elif key == "max_size_bytes": self.parameters["max_size_bytes"] = kwargs[key] elif key == "elastic_pool_name": - self.parameters["elastic_pool_name"] = kwargs[key] + self.parameters["elastic_pool_id"] = kwargs[key] elif key == "read_scale": self.parameters["read_scale"] = 'Enabled' if kwargs[key] else 'Disabled' elif key == "sample_name": @@ -358,6 +358,9 @@ class AzureRMSqlDatabase(AzureRMModuleBase): if "location" not in self.parameters: self.parameters["location"] = resource_group.location + if "elastic_pool_id" in self.parameters: + self.format_elastic_pool_id() + old_response = self.get_sqldatabase() if not old_response: @@ -486,6 +489,14 @@ class AzureRMSqlDatabase(AzureRMModuleBase): return False + def format_elastic_pool_id(self): + parrent_id = format_resource_id(val=self.server_name, + subscription_id=self.subscription_id, + namespace="Microsoft.Sql", + types="servers", + resource_group=self.resource_group) + self.parameters['elastic_pool_id'] = parrent_id + "/elasticPools/" + self.parameters['elastic_pool_id'] + def _snake_to_camel(snake, capitalize_first=False): if capitalize_first: