Skip to content

Commit da2e3e1

Browse files
authored
[Spring Cloud] Support zone redundant while service instance creating (#4253)
1 parent a4f86e7 commit da2e3e1

6 files changed

Lines changed: 1293 additions & 7 deletions

File tree

src/spring-cloud/azext_spring_cloud/_enterprise.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def spring_cloud_create(cmd, client, resource_group, name, location=None,
1717
service_runtime_network_resource_group=None, app_network_resource_group=None,
1818
app_insights_key=None, app_insights=None, sampling_rate=None,
1919
disable_app_insights=None, enable_java_agent=None,
20-
sku=None, tags=None, no_wait=False):
20+
sku=None, tags=None, zone_redundant=False, no_wait=False):
2121
"""
2222
This method creates Azure Spring Cloud enterprise tier instance, it also creates sub-component under the instance if
2323
user enable these component.
@@ -29,6 +29,7 @@ def spring_cloud_create(cmd, client, resource_group, name, location=None,
2929
reserved_cidr_range=reserved_cidr_range,
3030
service_runtime_network_resource_group=service_runtime_network_resource_group,
3131
app_network_resource_group=app_network_resource_group,
32+
zone_redundant=zone_redundant,
3233
sku=sku,
3334
tags=tags)
3435
return poller

src/spring-cloud/azext_spring_cloud/_params.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def load_arguments(self, _):
7272
"--app-insights-key or --app-insights, "
7373
"will create a new Application Insights instance in the same resource group.",
7474
validator=validate_tracing_parameters_asc_create)
75+
c.argument('zone_redundant',
76+
arg_type=get_three_state_flag(),
77+
help="Create your Azure Spring Cloud service in an Azure availability zone or not, "
78+
"this could only be supported in several regions at the moment ",
79+
default=False, is_preview=True)
7580

7681
with self.argument_context('spring-cloud update') as c:
7782
c.argument('sku', arg_type=sku_type)

src/spring-cloud/azext_spring_cloud/custom.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def spring_cloud_create(cmd, client, resource_group, name, location=None,
6464
service_runtime_network_resource_group=None, app_network_resource_group=None,
6565
app_insights_key=None, app_insights=None, sampling_rate=None,
6666
disable_app_insights=None, enable_java_agent=None,
67-
sku=None, tags=None, no_wait=False):
67+
sku=None, tags=None, zone_redundant=False, no_wait=False):
6868
"""
6969
Note: This is the command for create Spring-Cloud Standard and Basic tier. Refer tier_routing_spring_cloud.py for
7070
the command definition. And _enteprise.py for Spring-Cloud Enterprise tier creation.
@@ -85,6 +85,7 @@ def spring_cloud_create(cmd, client, resource_group, name, location=None,
8585
reserved_cidr_range=reserved_cidr_range,
8686
service_runtime_network_resource_group=service_runtime_network_resource_group,
8787
app_network_resource_group=app_network_resource_group,
88+
zone_redundant=zone_redundant,
8889
sku=sku,
8990
tags=tags)
9091
_update_application_insights_asc_create(cmd, resource_group, name, location,
@@ -96,21 +97,23 @@ def spring_cloud_create(cmd, client, resource_group, name, location=None,
9697
def _create_service(cmd, client, resource_group, name, location=None,
9798
service_runtime_subnet=None, app_subnet=None, reserved_cidr_range=None,
9899
service_runtime_network_resource_group=None, app_network_resource_group=None,
100+
zone_redundant=False,
99101
sku=None, tags=None):
100102
if location is None:
101103
location = _get_rg_location(cmd.cli_ctx, resource_group)
102-
properties = models.ClusterResourceProperties()
104+
properties = models_20220101preview.ClusterResourceProperties()
103105

104106
if service_runtime_subnet or app_subnet or reserved_cidr_range:
105-
properties.network_profile = models.NetworkProfile(
107+
properties.network_profile = models_20220101preview.NetworkProfile(
106108
service_runtime_subnet_id=service_runtime_subnet,
107109
app_subnet_id=app_subnet,
108110
service_cidr=reserved_cidr_range,
109111
app_network_resource_group=app_network_resource_group,
110112
service_runtime_network_resource_group=service_runtime_network_resource_group
111113
)
112114

113-
resource = models.ServiceResource(location=location, sku=sku, properties=properties, tags=tags)
115+
properties.zone_redundant = zone_redundant
116+
resource = models_20220101preview.ServiceResource(location=location, sku=sku, properties=properties, tags=tags)
114117

115118
poller = client.services.begin_create_or_update(
116119
resource_group, name, resource)
@@ -148,7 +151,7 @@ def spring_cloud_update(cmd, client, resource_group, name, app_insights_key=None
148151
Will be decommissioned in future releases.
149152
:param app_insights_key: Connection string or Instrumentation key
150153
"""
151-
updated_resource = models.ServiceResource()
154+
updated_resource = models_20220101preview.ServiceResource()
152155
update_service_tags = False
153156
update_service_sku = False
154157

@@ -159,7 +162,7 @@ def spring_cloud_update(cmd, client, resource_group, name, app_insights_key=None
159162

160163
resource = client.services.get(resource_group, name)
161164
location = resource.location
162-
updated_resource_properties = models.ClusterResourceProperties()
165+
updated_resource_properties = models_20220101preview.ClusterResourceProperties()
163166

164167
_update_application_insights_asc_update(cmd, resource_group, name, location,
165168
app_insights_key, app_insights, disable_app_insights, no_wait)

0 commit comments

Comments
 (0)