Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Front Door] Add update func for backend and fix backend_host_header #3394

Merged
merged 10 commits into from
Jul 1, 2021
5 changes: 5 additions & 0 deletions src/front-door/azext_front_door/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
short-summary: Add a backend to a Front Door backend pool.
"""

helps['network front-door backend-pool backend update'] = """
type: command
short-summary: Update a backend to a Front Door backend pool.
"""

helps['network front-door backend-pool backend list'] = """
type: command
short-summary: List backends of a Front Door backend pool.
Expand Down
4 changes: 2 additions & 2 deletions src/front-door/azext_front_door/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ def load_arguments(self, _):
c.argument('https_port', type=int, help='HTTPS TCP port number.')
c.argument('weight', type=int, help='Weight of this endpoint for load balancing purposes.')
c.argument('private_link_alias', help='The Alias of the Private Link resource. Populating this optional field indicates that this backend is \'Private\'.')
c.argument('private_link_resource_id', help='The Resource Id of the Private Link. Populating this optional field indicates that this backend is \'Private\'.')
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\'.')
c.argument('private_link_location', help='The location of the Private Link resource. Required only if \'privateLinkResourceId\' is populated.')
c.argument('private_link_approval_message', help='A custom message to be included in the approval request to connect to the Private Link.')
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.')
c.argument('backend_host_header', help='Host header sent to the backend.')
c.argument('backend_pool_name', options_list='--pool-name', help='Name of the backend pool.')
c.argument('index', type=int, help='Index of the backend to remove (starting with 1).')
Expand Down
1 change: 1 addition & 0 deletions src/front-door/azext_front_door/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def load_command_table(self, _):

with self.command_group('network front-door backend-pool backend', frontdoor_sdk) as g:
g.custom_command('add', 'add_fd_backend')
g.custom_command('update', 'update_fd_backend')
g.custom_command('list', 'list_fd_backends')
g.custom_command('remove', 'remove_fd_backend')

Expand Down
216 changes: 126 additions & 90 deletions src/front-door/azext_front_door/custom.py

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ interactions:
accept-language:
- en-US
method: GET
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
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
response:
body:
string: '{"code":"NotFound","message":"The resource record ''clife000002'' does
Expand Down Expand Up @@ -404,7 +404,7 @@ interactions:
accept-language:
- en-US
method: PUT
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
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
response:
body:
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"}}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer)
from knack.util import CLIError


class BackendPoolScenarioTest(ScenarioTest):
Expand Down Expand Up @@ -37,3 +38,59 @@ def test_backend_pool_basic(self, resource_group):
checks=[
self.check('length(@)', 1),
])

@ResourceGroupPreparer(location='westus')
def test_backend_pool_backend(self, resource_group):
self.kwargs.update({
'front_door': self.create_random_name('clifrontdoor', 20),
'bkp1': 'bkp1',
'lb1': 'lb1',
'pb1': 'pb1'
})
self.cmd('network front-door create -g {rg} -n {front_door} --backend-address 202.120.2.3')

self.cmd('network front-door backend-pool create -f {front_door} -g {rg} -n {bkp1} '
'--address 202.120.2.3 '
'--load-balancing DefaultLoadBalancingSettings '
'--probe DefaultProbeSettings ',
checks=[
self.check('backends[0].address', '202.120.2.3'),
self.check('ends_with(loadBalancingSettings.id, `DefaultLoadBalancingSettings`)', True),
self.check('ends_with(healthProbeSettings.id, `DefaultProbeSettings`)', True)
])

# Fix Issue: https://github.com/Azure/azure-cli/issues/17269
self.cmd('network front-door backend-pool backend add '
'--resource-group {rg} '
'--front-door-name {front_door} '
'--pool-name {bkp1} '
'--address 202.120.2.3 '
'--backend-host-header "" '
'--disabled true '
'--http-port 80 '
'--https-port 443 '
'--priority 2 '
'--weight 1 ',
checks=[
self.check('backendHostHeader', '')
])

# Fix Iussue: https://github.com/Azure/azure-cli/issues/17270
self.cmd('network front-door backend-pool backend update '
'--resource-group {rg} '
'--front-door-name {front_door} '
'--pool-name {bkp1} '
'--index 2 '
'--disabled false ',
checks=[
self.check('enabledState', 'Enabled'),
self.check('backendHostHeader', '')
])

with self.assertRaises(CLIError):
self.cmd('network front-door backend-pool backend update '
'--resource-group {rg} '
'--front-door-name {front_door} '
'--pool-name {bkp1} '
'--index 3 '
'--disabled false ')