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 Service] az functionapp/logicapp create: Add new --https-only parameter #23213

Merged
merged 17 commits into from
Jul 26, 2022
Merged
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 @@ -235,7 +235,7 @@ def default_api_version(self):
'subscription_diagnostic_settings': '2017-05-01-preview'
}),
ResourceType.MGMT_MSI: '2021-09-30-preview',
ResourceType.MGMT_APPSERVICE: '2021-03-01',
ResourceType.MGMT_APPSERVICE: '2022-03-01',
ResourceType.MGMT_IOTHUB: '2021-07-02',
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 @@ -153,8 +153,6 @@ def load_arguments(self, _):
local_context_attribute=LocalContextAttribute(name='plan_name', actions=[LocalContextAction.GET]))
c.argument('vnet', help="Name or resource ID of the regional virtual network. If there are multiple vnets of the same name across different resource groups, use vnet resource id to specify which vnet to use. If vnet name is used, by default, the vnet in the same resource group as the webapp will be used. Must be used with --subnet argument.")
c.argument('subnet', help="Name or resource ID of the pre-existing subnet to have the webapp join. The --vnet is argument also needed if specifying subnet by name.")
c.argument('https_only', help="Redirect all traffic made to an app using HTTP to HTTPS.",
arg_type=get_three_state_flag(return_label=True))
c.ignore('language')
c.ignore('using_webapp_up')

Expand Down Expand Up @@ -234,6 +232,8 @@ def load_arguments(self, _):
c.argument('deployment_source_branch', options_list=['--deployment-source-branch', '-b'],
help='the branch to deploy')
c.argument('tags', arg_type=tags_type)
c.argument('https_only', help="Redirect all traffic made to an app using HTTP to HTTPS.",
arg_type=get_three_state_flag())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the return_label be TRUE here - since this change will impact webapp up where we default this to True?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this and return_label=True causes broken behavior when the user calls this as --https-only false. Having return_label=True results in the value being passed as a string (ie "true" or "false") instead of a boolean value (True or False). This behavior is explained in the documentation in the screenshot below. The result is that if we had return_label=True and the user called the command with --https-only false, they would have a webapp with httpsOnly true.

I just doubled check this and it doesn't impact webapps created with az webapp up -- they still are httpsOnly by default:
Screen Shot 2022-07-25 at 12 48 11 PM

Documentation for the return_label argument:
Screen Shot 2022-07-25 at 12 38 11 PM


for scope in ['webapp', 'functionapp']:
with self.argument_context(scope) as c:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def validate_vnet_integration(cmd, namespace):
resource_group_name=namespace.resource_group_name)

sku_name = plan_info.sku.name
disallowed_skus = {'FREE', 'SHARED', 'BASIC', 'ElasticPremium', 'PremiumContainer', 'Isolated', 'IsolatedV2'}
disallowed_skus = {'FREE', 'SHARED', 'PremiumContainer', 'Isolated', 'IsolatedV2'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we confirm with function apps team this list accurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We confirmed this on the original email thread with the functions team that prompted this change

if get_sku_tier(sku_name) in disallowed_skus:
raise ArgumentUsageError("App Service Plan has invalid sku for vnet integration: {}."
"Plan sku cannot be one of: {}. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3415,7 +3415,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non
deployment_source_branch='master', deployment_local_git=None,
docker_registry_server_password=None, docker_registry_server_user=None,
deployment_container_image_name=None, tags=None, assign_identities=None,
role='Contributor', scope=None, vnet=None, subnet=None):
role='Contributor', scope=None, vnet=None, subnet=None, https_only=False):
# pylint: disable=too-many-statements, too-many-branches
if functions_version is None:
logger.warning("No functions version specified so defaulting to 3. In the future, specifying a version will "
Expand Down Expand Up @@ -3462,7 +3462,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non
subnet_resource_id = None

functionapp_def = Site(location=None, site_config=site_config, tags=tags,
virtual_network_subnet_id=subnet_resource_id)
virtual_network_subnet_id=subnet_resource_id, https_only=https_only)

plan_info = None
if runtime is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_logicapp(cmd, resource_group_name, name, storage_account, plan=None,
app_insights=None, app_insights_key=None, disable_app_insights=None,
deployment_source_url=None, deployment_source_branch='master', deployment_local_git=None,
docker_registry_server_password=None, docker_registry_server_user=None,
deployment_container_image_name=None, tags=None):
deployment_container_image_name=None, tags=None, https_only=False):
# pylint: disable=too-many-statements, too-many-branches, too-many-locals
functions_version = DEFAULT_LOGICAPP_FUNCTION_VERSION
runtime = None
Expand All @@ -65,7 +65,7 @@ def create_logicapp(cmd, resource_group_name, name, storage_account, plan=None,
deployment_container_image_name)

site_config = SiteConfig(app_settings=[])
logicapp_def = Site(location=None, site_config=site_config, tags=tags)
logicapp_def = Site(location=None, site_config=site_config, tags=tags, https_only=https_only)
client = web_client_factory(cmd.cli_ctx)
plan_info = None
if runtime is not None:
Expand Down
Loading