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

[App Services] Support DNL scopes during Site Creation #30997

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def default_api_version(self):
'subscription_diagnostic_settings': '2017-05-01-preview'
}),
ResourceType.MGMT_MSI: '2023-01-31',
ResourceType.MGMT_APPSERVICE: '2023-01-01',
ResourceType.MGMT_APPSERVICE: '2024-04-01',
ResourceType.MGMT_IOTHUB: '2023-06-30-preview',
ResourceType.MGMT_IOTDPS: '2021-10-15',
ResourceType.MGMT_IOTCENTRAL: '2021-11-01-preview',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def load_arguments(self, _):
c.argument('acr_identity', help='Accept system or user assigned identity which will be set for acr image pull. '
'Use \'[system]\' to refer system assigned identity, or a resource id to refer user assigned identity.')
c.argument('basic_auth', help='Enable or disable basic auth for both SCM and FTP Basic Auth Publishing Credentials. Defaults to Enabled if not specified. See https://aka.ms/app-service-basic-auth to learn more.', arg_type=get_enum_type(BASIC_AUTH_TYPES))
c.argument('auto_generated_domain_name_label_scope', options_list=['--domain-name-scope'], help="Specifies the scope of uniqueness for the default hostname during resource creation. ", choices=['TenantReuse', 'SubscriptionReuse', 'ResourceGroupReuse', 'NoReuse'])
c.ignore('language')
c.ignore('using_webapp_up')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def create_webapp(cmd, resource_group_name, name, plan, runtime=None, startup_fi
multicontainer_config_type=None, multicontainer_config_file=None, tags=None,
using_webapp_up=False, language=None, assign_identities=None,
role='Contributor', scope=None, vnet=None, subnet=None, https_only=False,
public_network_access=None, acr_use_identity=False, acr_identity=None, basic_auth=""):
public_network_access=None, acr_use_identity=False, acr_identity=None, basic_auth="",
auto_generated_domain_name_label_scope=None):
from azure.mgmt.web.models import Site
from azure.core.exceptions import ResourceNotFoundError as _ResourceNotFoundError
SiteConfig, SkuDescription, NameValuePair = cmd.get_models(
Expand Down Expand Up @@ -221,7 +222,8 @@ def create_webapp(cmd, resource_group_name, name, plan, runtime=None, startup_fi

webapp_def = Site(location=location, site_config=site_config, server_farm_id=plan_info.id, tags=tags,
https_only=https_only, virtual_network_subnet_id=subnet_resource_id,
public_network_access=public_network_access, vnet_route_all_enabled=vnet_route_all_enabled)
public_network_access=public_network_access, vnet_route_all_enabled=vnet_route_all_enabled,
auto_generated_domain_name_label_scope=auto_generated_domain_name_label_scope)
if runtime:
runtime = _StackRuntimeHelper.remove_delimiters(runtime)

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3225,5 +3225,34 @@ def test_webapp_list_show_details(self, resource_group):
JMESPathCheck('[0].siteConfig.javaContainerVersion', '10.0'),
])

class WebappDNLTests(ScenarioTest):
@AllowLargeResponse(8192)
@ResourceGroupPreparer(location=WINDOWS_ASP_LOCATION_WEBAPP)
def test_webapp_dnl(self, resource_group):
webapp_name = self.create_random_name(prefix='webapp-dnl', length=24)
plan = self.create_random_name(prefix='webapp-dnl-plan', length=24)

self.cmd('appservice plan create -g {} -n {}'.format(resource_group, plan))
self.cmd('appservice plan list -g {}'.format(resource_group), checks=[
JMESPathCheck('length(@)', 1),
JMESPathCheck('[0].name', plan),
JMESPathCheck('[0].perSiteScaling', False)
])

result = self.cmd('webapp create -g {} -n {} --plan {} --auto-generated-domain-name-label-scope {}'.format(
resource_group, webapp_name, plan, 'TenantReuse'), checks=[
JMESPathCheck('state', 'Running'),
JMESPathCheck('name', webapp_name),
JMESPathCheck('autoGeneratedDomainNameLabelScope', 'TenantReuse')
]).get_output_in_json()

default_hostname = result.get('defaultHostName')
pattern = r'^([a-zA-Z0-9\-]+)-([a-z0-9]{16})\.([a-z]+-\d{2})\.azurewebsites\.net$'
match = re.match(pattern, default_hostname)
self.assertIsNotNone(match, "defaultHostName '{}' does not match expected pattern".format(default_hostname))
app_name, hash_part, region = match.groups()
self.assertTrue(len(hash_part) == 16 and hash_part.islower(), "Hash is not 16 chars or not lowercase.")
self.assertIn('-', region, "Region part does not have '-' separator.")

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ azure-mgmt-sqlvirtualmachine==1.0.0b5
azure-mgmt-storage==22.1.0
azure-mgmt-synapse==2.1.0b5
azure-mgmt-trafficmanager==1.0.0
azure-mgmt-web==7.3.1
azure-mgmt-web==8.0.0
azure-monitor-query==1.2.0
azure-multiapi-storage==1.3.0
azure-nspkg==3.0.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ azure-mgmt-sqlvirtualmachine==1.0.0b5
azure-mgmt-storage==22.1.0
azure-mgmt-synapse==2.1.0b5
azure-mgmt-trafficmanager==1.0.0
azure-mgmt-web==7.3.1
azure-mgmt-web==8.0.0
azure-monitor-query==1.2.0
azure-multiapi-storage==1.3.0
azure-nspkg==3.0.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ azure-mgmt-sqlvirtualmachine==1.0.0b5
azure-mgmt-storage==22.1.0
azure-mgmt-synapse==2.1.0b5
azure-mgmt-trafficmanager==1.0.0
azure-mgmt-web==7.3.1
azure-mgmt-web==8.0.0
azure-monitor-query==1.2.0
azure-multiapi-storage==1.3.0
azure-nspkg==3.0.2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
'azure-mgmt-storage==22.1.0',
'azure-mgmt-synapse==2.1.0b5',
'azure-mgmt-trafficmanager~=1.0.0',
'azure-mgmt-web==7.3.1',
'azure-mgmt-web==8.0.0',
'azure-monitor-query==1.2.0',
'azure-multiapi-storage~=1.3.0',
'azure-storage-common~=1.4',
Expand Down