Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

Some `az functionapp` commands don't work for Flex Consumption SKU #30380

Open mattchenderson opened 2 hours ago

mattchenderson commented 2 hours ago

Describe the bug

When using the Flex Consumption SKU, some commands get an error message citing an API version issue. An example of this is when assigning a user-assigned identity to the function app (either during creation or after creation).

This seems like it should work for any command which does a GET-modify-PUT loop from the App Service / Functions commands. It does not impact specific Flex Consumption commands, presumably because they use an alternative path. The issue seems to be for shared commands.

Related command

az functionapp identity assign --resource-group <groupName> --identities <uami> --name <appName>--debug

Errors

Site.FunctionAppConfig is invalid. It is only supported for 2023-12-01 api-version or newer

Issue script & Debug output

Truncated to relevant response content:

cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"Code":"BadRequest","Message":"Site.FunctionAppConfig is invalid.  It is only supported for 2023-12-01 api-version or newer.","Target":null,"Details":[{"Message":"Site.FunctionAppConfig is invalid.  It is only supported for 2023-12-01 api-version or newer."},{"Code":"BadRequest"},{"ErrorEntity":{"ExtendedCode":"51021","MessageTemplate":"{0} is invalid.  {1}","Parameters":["Site.FunctionAppConfig","It is only supported for 2023-12-01 api-version or newer."],"Code":"BadRequest","Message":"Site.FunctionAppConfig is invalid.  It is only supported for 2023-12-01 api-version or newer."}}],"Innererror":null}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/usr/lib64/az/lib/python3.9/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/appservice/custom.py", line 1288, in assign_identity
    webapp = _assign_identity(cmd.cli_ctx, getter, setter, identity_role=role, identity_scope=scope)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/core/commands/arm.py", line 721, in assign_identity
    resource = setter(resource)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/appservice/custom.py", line 1283, in setter
    poller = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'begin_create_or_update',
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/cli/command_modules/appservice/_appservice_utils.py", line 21, in _generic_site_operation
    if extra_parameter is None else operation(resource_group_name,
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/web/v2023_01_01/operations/_web_apps_operations.py", line 17008, in begin_create_or_update
    raw_result = self._create_or_update_initial(
  File "/usr/lib64/az/lib/python3.9/site-packages/azure/mgmt/web/v2023_01_01/operations/_web_apps_operations.py", line 16870, in _create_or_update_initial
    raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Bad Request'
Content: {"Code":"BadRequest","Message":"Site.FunctionAppConfig is invalid.  It is only supported for 2023-12-01 api-version or newer.","Target":null,"Details":[{"Message":"Site.FunctionAppConfig is invalid.  It is only supported for 2023-12-01 api-version or newer."},{"Code":"BadRequest"},{"ErrorEntity":{"ExtendedCode":"51021","MessageTemplate":"{0} is invalid.  {1}","Parameters":["Site.FunctionAppConfig","It is only supported for 2023-12-01 api-version or newer."],"Code":"BadRequest","Message":"Site.FunctionAppConfig is invalid.  It is only supported for 2023-12-01 api-version or newer."}}],"Innererror":null}

cli.azure.cli.core.azclierror: Operation returned an invalid status 'Bad Request'
az_command_data_logger: Operation returned an invalid status 'Bad Request'

Expected behavior

The command should complete without errors as it does for other SKUs.

Environment Summary

This was originally found using Cloud Shell (below), but seems to also reproduce on 2.66.

az --version
azure-cli                         2.65.0 *

core                              2.65.0 *
telemetry                          1.1.0

Extensions:
ai-examples                        0.2.5
containerapp                      0.3.53
ml                                2.30.1
ssh                                2.0.5

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Additional context

I believe this to be rooted in the version of azure-mgmt-web being referenced. The current version is 7.2.0 (from 2023-11-19). The latest version is 7.3.1 (from 2024-08-19). With the newer version, the default version will move to 2024-04-01, which should be tolerated.

azure-client-tools-bot-prd[bot] commented 2 hours ago

Hi @mattchenderson,

2.65.0 is not the latest Azure CLI(2.66.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

microsoft-github-policy-service[bot] commented 2 hours ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AnatoliB, @Francisco-Gamino, @shreyabatra4.

yonzhan commented 2 hours ago

route to service team