Skip to content

Commit aa0d22e

Browse files
authored
[Front Door] Add update func for backend and fix backend_host_header (Azure#3394)
* [Front Door] Add update func for backend and fix backend_host_header judgment in create func * fix linter * fix * fix option_length_too_long * fix test * Remove CLIError and fix backend index range * fix style * get updated backend * update history and version
1 parent cea0bd0 commit aa0d22e

File tree

9 files changed

+1693
-95
lines changed

9 files changed

+1693
-95
lines changed

src/front-door/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
1.0.15
7+
++++++
8+
* Add az network front-door backend-pool backend update command: Update a backend to Front Door backend pool.
9+
* Fix backend related bugs
10+
611
1.0.14
712
++++++
813
* Migrate to Track2 SDK.

src/front-door/azext_front_door/_help.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
short-summary: Add a backend to a Front Door backend pool.
9999
"""
100100

101+
helps['network front-door backend-pool backend update'] = """
102+
type: command
103+
short-summary: Update a backend to a Front Door backend pool.
104+
"""
105+
101106
helps['network front-door backend-pool backend list'] = """
102107
type: command
103108
short-summary: List backends of a Front Door backend pool.

src/front-door/azext_front_door/_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def load_arguments(self, _):
129129
c.argument('https_port', type=int, help='HTTPS TCP port number.')
130130
c.argument('weight', type=int, help='Weight of this endpoint for load balancing purposes.')
131131
c.argument('private_link_alias', help='The Alias of the Private Link resource. Populating this optional field indicates that this backend is \'Private\'.')
132-
c.argument('private_link_resource_id', help='The Resource Id of the Private Link. Populating this optional field indicates that this backend is \'Private\'.')
132+
c.argument('private_link_resource_id', options_list=['--private-link-resource-id', '--resource-id'], help='The Resource Id of the Private Link. Populating this optional field indicates that this backend is \'Private\'.')
133133
c.argument('private_link_location', help='The location of the Private Link resource. Required only if \'privateLinkResourceId\' is populated.')
134-
c.argument('private_link_approval_message', help='A custom message to be included in the approval request to connect to the Private Link.')
134+
c.argument('private_link_approval_message', options_list=['--private-link-approval-message', '--approval-message'], help='A custom message to be included in the approval request to connect to the Private Link.')
135135
c.argument('backend_host_header', help='Host header sent to the backend.')
136136
c.argument('backend_pool_name', options_list='--pool-name', help='Name of the backend pool.')
137137
c.argument('index', type=int, help='Index of the backend to remove (starting with 1).')

src/front-door/azext_front_door/commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def load_command_table(self, _):
105105

106106
with self.command_group('network front-door backend-pool backend', frontdoor_sdk) as g:
107107
g.custom_command('add', 'add_fd_backend')
108+
g.custom_command('update', 'update_fd_backend')
108109
g.custom_command('list', 'list_fd_backends')
109110
g.custom_command('remove', 'remove_fd_backend')
110111

src/front-door/azext_front_door/custom.py

Lines changed: 126 additions & 90 deletions
Large diffs are not rendered by default.

src/front-door/azext_front_door/tests/latest/recordings/test_backend_pool_backend.yaml

Lines changed: 1494 additions & 0 deletions
Large diffs are not rendered by default.

src/front-door/azext_front_door/tests/latest/recordings/test_front_door_basic_scenario.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ interactions:
354354
accept-language:
355355
- en-US
356356
method: GET
357-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/azfdtest.xyz/providers/Microsoft.Network/dnsZones/cdne2e.azfdtest.xyz/CNAME/clife000002?api-version=2018-05-01
357+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/azfdtest.xyz/providers/Microsoft.Network/dnsZones/cdne2e.azfdtest.xyz/cname/clife000002?api-version=2018-05-01
358358
response:
359359
body:
360360
string: '{"code":"NotFound","message":"The resource record ''clife000002'' does
@@ -404,7 +404,7 @@ interactions:
404404
accept-language:
405405
- en-US
406406
method: PUT
407-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/azfdtest.xyz/providers/Microsoft.Network/dnsZones/cdne2e.azfdtest.xyz/CNAME/clife000002?api-version=2018-05-01
407+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/azfdtest.xyz/providers/Microsoft.Network/dnsZones/cdne2e.azfdtest.xyz/cname/clife000002?api-version=2018-05-01
408408
response:
409409
body:
410410
string: '{"id":"\/subscriptions\/00000000-0000-0000-0000-000000000000\/resourceGroups\/azfdtest.xyz\/providers\/Microsoft.Network\/dnszones\/cdne2e.azfdtest.xyz\/CNAME\/clife000002","name":"clife000002","type":"Microsoft.Network\/dnszones\/CNAME","etag":"bd9175a9-254c-4134-8aa2-9d23be6112b0","properties":{"fqdn":"clife000002.cdne2e.azfdtest.xyz.","TTL":3600,"CNAMERecord":{"cname":"clifrontdoor000003.azurefd.net"},"targetResource":{},"provisioningState":"Succeeded"}}'

src/front-door/azext_front_door/tests/latest/test_backend_pool_scenarios.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer)
6+
from knack.util import CLIError
67

78

89
class BackendPoolScenarioTest(ScenarioTest):
@@ -37,3 +38,59 @@ def test_backend_pool_basic(self, resource_group):
3738
checks=[
3839
self.check('length(@)', 1),
3940
])
41+
42+
@ResourceGroupPreparer(location='westus')
43+
def test_backend_pool_backend(self, resource_group):
44+
self.kwargs.update({
45+
'front_door': self.create_random_name('clifrontdoor', 20),
46+
'bkp1': 'bkp1',
47+
'lb1': 'lb1',
48+
'pb1': 'pb1'
49+
})
50+
self.cmd('network front-door create -g {rg} -n {front_door} --backend-address 202.120.2.3')
51+
52+
self.cmd('network front-door backend-pool create -f {front_door} -g {rg} -n {bkp1} '
53+
'--address 202.120.2.3 '
54+
'--load-balancing DefaultLoadBalancingSettings '
55+
'--probe DefaultProbeSettings ',
56+
checks=[
57+
self.check('backends[0].address', '202.120.2.3'),
58+
self.check('ends_with(loadBalancingSettings.id, `DefaultLoadBalancingSettings`)', True),
59+
self.check('ends_with(healthProbeSettings.id, `DefaultProbeSettings`)', True)
60+
])
61+
62+
# Fix Issue: https://github.com/Azure/azure-cli/issues/17269
63+
self.cmd('network front-door backend-pool backend add '
64+
'--resource-group {rg} '
65+
'--front-door-name {front_door} '
66+
'--pool-name {bkp1} '
67+
'--address 202.120.2.3 '
68+
'--backend-host-header "" '
69+
'--disabled true '
70+
'--http-port 80 '
71+
'--https-port 443 '
72+
'--priority 2 '
73+
'--weight 1 ',
74+
checks=[
75+
self.check('backendHostHeader', '')
76+
])
77+
78+
# Fix Iussue: https://github.com/Azure/azure-cli/issues/17270
79+
self.cmd('network front-door backend-pool backend update '
80+
'--resource-group {rg} '
81+
'--front-door-name {front_door} '
82+
'--pool-name {bkp1} '
83+
'--index 2 '
84+
'--disabled false ',
85+
checks=[
86+
self.check('enabledState', 'Enabled'),
87+
self.check('backendHostHeader', '')
88+
])
89+
90+
with self.assertRaises(CLIError):
91+
self.cmd('network front-door backend-pool backend update '
92+
'--resource-group {rg} '
93+
'--front-door-name {front_door} '
94+
'--pool-name {bkp1} '
95+
'--index 3 '
96+
'--disabled false ')

src/front-door/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from codecs import open
99
from setuptools import setup, find_packages
1010

11-
VERSION = "1.0.14"
11+
VERSION = "1.0.15"
1212

1313
CLASSIFIERS = [
1414
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)