azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az webapp config set --generic-configurations failed

Open PuffTMD opened this issue 7 years ago • 10 comments

This is autogenerated. Please review and update as needed.

Describe the bug

When adding in --generic-configuraitons "{"clientAffinityEnabled": false}" to the webapp config set commands I receive an unexpected error.

Command Name --generic-configurations "{"clientAffinityEnabled": false}"

Errors:

not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
azure/cli/core/util.py, ln 244, in shell_safe_json_parse
    return json.loads(json_or_dict_string)
lib/python3.6/json/__init__.py, ln 354, in loads
    return _default_decoder.decode(s)
lib/python3.6/json/decoder.py, ln 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
lib/python3.6/json/decoder.py, ln 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

...

cli/command_modules/appservice/custom.py, ln 788, in update_site_configs
    config_name, value = s.split('=', 1)
ValueError: not enough values to unpack (expected 2, got 1)

To Reproduce:

add --generic-configurations into the webapp config set command

  • Put any pre-requisite steps here...
  • az webapp config set -g {} -n {} --generic-configurations {"clientAffinityEnabled": false} --slot {stagging} --ftps-state {Disabled} --php-version {5.6} --http20-enabled {true}

Expected Behavior

Update the ARR Affinity setting to false

Environment Summary

Linux-4.9.184-linuxkit-x86_64-with
Python 3.6.4
Shell: bash

azure-cli 2.0.71

Extensions:
interactive 0.4.3

Additional Context

PuffTMD avatar Aug 15 '19 09:08 PuffTMD

@MyronFanQiu the documentation example is misleading on the usage here to use --generic-configurations, add the JSON object to a son file & run the command as az webapp config set -g {}-n {} --generic-configurations @test.json & see if that works.

@yugangw-msft looking at the code the usage of the command as given in the documentation incorrect az webapp config set -g MyResourceGroup -n MyUniqueApp --generic-configurations "{"alwaysOn": true}" I wanted to check with you if this was originally supported & got regressed, since you originally implemented it. Please comment. Thanks!

panchagnula avatar Aug 20 '19 20:08 panchagnula

The command missing the wrapping quotes: "{\"clientAffinityEnabled\": false}" We have a doc here with suggestions of how to handle quotes. Right now, we need to fix the sample from -h which misses the quotes

 turn on "alwaysOn" through a json with content '{"alwaysOn", true}'
        az webapp config set -g MyResourceGroup -n MyUniqueApp --generic-configurations
        "{"alwaysOn": true}"

yugangw-msft avatar Aug 20 '19 23:08 yugangw-msft

client-affinity-enabled can only be set with webapp udpdate and not webapp config set.

PuffTMD avatar Aug 21 '19 07:08 PuffTMD

then we will use this issue to track the doc issue on az webapp config set

yugangw-msft avatar Aug 21 '19 12:08 yugangw-msft

clientAffinityEnabled is a site Object property so we use this command https://docs.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-update

--set is the equivalent of --generic-configurations so you can try using that as well.

panchagnula avatar Aug 21 '19 19:08 panchagnula

@yugangw-msft The help changes got undone in the commit after yours: https://github.com/Azure/azure-cli/commit/573d0640d1b738bd1fb57d674f583da0ad5a608d#diff-40e30572983a53c248e7106702aabcc2L867 - so it's again not ok.

The suggested doc regarding handling quotes was helpful though!

eholman avatar Sep 08 '20 22:09 eholman

As of June 2021, v2.24.2, az webapp config set paramater --generic-configurations doesn't seem to be working, what is the current status?

az webapp config set -g myGroup -n myAppName --generic-configurations '{ "managedPipelineMode": "Classic" }'

Errors :

`The command failed with an unexpected error. Here is the traceback:
not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/util.py", line 506, in shell_safe_json_parse
    return json.loads(json_or_dict_string, strict=strict)
  File "/opt/az/lib/python3.6/json/__init__.py", line 367, in loads
    return cls(**kw).decode(s)
  File "/opt/az/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/az/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1169, in update_site_configs
    json_object = get_json_object(s)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/util.py", line 466, in get_json_object
    return _convert_to_snake_case(shell_safe_json_parse(json_string))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/util.py", line 531, in shell_safe_json_parse
    raise InvalidArgumentValueError(msg, recommendation=recommendation) from json_ex
azure.cli.core.azclierror.InvalidArgumentValueError: Failed to parse JSON: { managedPipelineMode: Classic }
Error detail: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1175, in update_site_configs
    config_name, value = s.split('=', 1)
ValueError: not enough values to unpack (expected 2, got 1)`

I also tried passing in as a json object --generic-configurations `@pipeClassic with the .json consisting of { "managedPipelineMode": "Classic" }

The command failed with an unexpected error. Here is the traceback:
not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/util.py", line 506, in shell_safe_json_parse
    return json.loads(json_or_dict_string, strict=strict)
  File "/opt/az/lib/python3.6/json/__init__.py", line 367, in loads
    return cls(**kw).decode(s)
  File "/opt/az/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/az/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1169, in update_site_configs
    json_object = get_json_object(s)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/util.py", line 466, in get_json_object
    return _convert_to_snake_case(shell_safe_json_parse(json_string))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/util.py", line 531, in shell_safe_json_parse
    raise InvalidArgumentValueError(msg, recommendation=recommendation) from json_ex
azure.cli.core.azclierror.InvalidArgumentValueError: Failed to parse JSON: @pipeClassic
Error detail: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 1175, in update_site_configs
    config_name, value = s.split('=', 1)
ValueError: not enough values to unpack (expected 2, got 1)

Other people (see comments above) have suggested alternative syntax involving backslashes "{\"managedPipelineMode\": \"Classic\"}" but no joy there.

The help for the param suggests "{"alwaysOn", true}" but it errors :

TRY THIS:
az webapp config set --resource-group MyResourceGroup --name MyUniqueApp --generic-configurations "{"
turn on "alwaysOn" through a json with content "{"alwaysOn", true}"

  1. the syntax is wrong for json, the comma doesn't belong, VS code warns 'Colon expectedjson(515)'. With corrected colon syntax {"alwaysOn": true} it also errors.

Instead of trying to set 'managedPipelineMode' to 'classic' let's try setting 'alwaysOn' as per the help example az webapp config set -g myGroup -n myAppName --generic-configurations '{"alwaysOn": true}'

(this produces the error as shown in example 1 above)

Can this issue be re-opened?

andrewt-vivaticket avatar Jun 12 '21 10:06 andrewt-vivaticket

@poplaar Your problem seems to be with your json input syntax. A Syntax like below worked to me in a Cmd/Win terminal. Hope it helps.

az webapp config set -g myGroup -n myAppName --generic-configurations "{\ "managedPipelineMode\": \"Classic\" }"

mvitor avatar Sep 17 '21 13:09 mvitor

az_generic @mvitor Thanks for the tip, but even with the syntax you suggest I receive the same errors as in the 12 Jun comment, ie 'Error detail: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)', 'ValueError: not enough values to unpack (expected 2, got 1)'

I have uploaded an image of how the Azure Cloud Shell app displays the command after typing it on the command line. Note where some of the text is in blue, indicating it is not quite able to parse it.

andrewt-vivaticket avatar Dec 24 '21 08:12 andrewt-vivaticket

Escape the double-quotes with a backtick, as documented in https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_quoting_rules?view=powershell-7.3. This worked for us:

az webapp config set -g ... -n ... --generic-configurations "{\`"managedPipelineMode\`": \`"Classic\`"}"

LexLuengas avatar Jun 19 '23 13:06 LexLuengas