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

az webapp config connection-string set: not enough values to unpack (expected 2, got 1) #28763

Closed
sc-draymond opened this issue Apr 16, 2024 · 6 comments
Assignees
Labels
app-service-general Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. Possible-Solution Service Attention This issue is responsible by Azure service team. Similar-Issue Web Apps az webapp

Comments

@sc-draymond
Copy link

Describe the bug

Running the command "az webapp config connection-string set" results in an error.

Related command

az webapp config connection-string set --connection-string-type SQLServer --name MyServer --resource-group MyResourceGroup --subscription MySubScription --settings ConnectionString="Data Source=tcp:MyServer.database.windows.net,1433;Initial Catalog=MyDatabase;User Id=MyID;Password=MyPassword;"

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 "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2021, in build_app_settings_input
File "json_init
.py", line 346, in loads
File "json\decoder.py", line 337, in decode
File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2048, in update_connection_strings
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2036, in _build_app_settings_input
ValueError: not enough values to unpack (expected 2, got 1)

Issue script & Debug output

cli.knack.cli: Command arguments: ['webapp', 'config', 'connection-string', 'set', '--connection-string-type', 'SQLServer', '--name', 'MyAppService', '--resource-group', 'MyResourceGroup', '--subscription', 'MySubscriptionID', '--settings', 'ConnectionString', '=Data Source=tcp:MySQLServer,1433;Initial Catalog=MyDatabase;User Id=MyID;Password=MyPassword;', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x000001E352F8B920>, <function OutputProducer.on_global_arguments at 0x000001E3531160C0>, <function CLIQuery.on_global_arguments at 0x000001E353143C40>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'webapp': ['azure.cli.command_modules.appservice', 'azure.cli.command_modules.serviceconnector']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: appservice 0.391 79 270
cli.azure.cli.core: serviceconnector 0.075 16 244
cli.azure.cli.core: Total (2) 0.466 95 514
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 93 groups, 514 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : webapp config connection-string set
cli.azure.cli.core: Command table: webapp config connection-string set
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001E355FFEF20>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\draymond.azure\commands\2024-04-16.15-32-38.webapp_config_connection-string_set.23440.log'.
az_command_data_logger: command args: webapp config connection-string set --connection-string-type {} --name {} --resource-group {} --subscription {} --settings {} {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x000001E356055440>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x000001E3560554E0>, <function register_cache_arguments..add_cache_arguments at 0x000001E356055620>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000001E353116160>, <function CLIQuery.handle_query_parameter at 0x000001E353143CE0>, <function register_ids_argument..parse_ids_arguments at 0x000001E356055580>]
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2021, in build_app_settings_input
File "json_init
.py", line 346, in loads
File "json\decoder.py", line 337, in decode
File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2048, in update_connection_strings
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2036, in _build_app_settings_input
ValueError: not enough values to unpack (expected 2, got 1)

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2021, in build_app_settings_input
File "json_init
.py", line 346, in loads
File "json\decoder.py", line 337, in decode
File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2048, in update_connection_strings
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2036, in _build_app_settings_input
ValueError: not enough values to unpack (expected 2, got 1)
az_command_data_logger: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2021, in build_app_settings_input
File "json_init
.py", line 346, in loads
File "json\decoder.py", line 337, in decode
File "json\decoder.py", line 355, in raw_decode
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2048, in update_connection_strings
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 2036, in build_app_settings_input
ValueError: not enough values to unpack (expected 2, got 1)
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x000001E355FFF1A0>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 1.692 seconds (init: 0.610, invoke: 1.082)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 7628 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry_init
.pyc C:\Users\draymond.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.

Expected behavior

The connection string would be set.

Environment Summary

azure-cli 2.59.0

core 2.59.0
telemetry 1.1.0

Extensions:
application-insights 1.2.1
azure-devops 1.0.0

Dependencies:
msal 1.27.0
azure-mgmt-resource 23.1.0b2

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\draymond.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

None

@sc-draymond sc-draymond added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Apr 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Web Apps az webapp Service Attention This issue is responsible by Azure service team. Auto-Assign Auto assign by bot app-service-general labels Apr 16, 2024
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 16, 2024

Thank you for opening this issue, we will look into it.

Copy link

Hi @sc-draymond
Find similar issue #11552.

Issue title Error configuration function app with powershell object for --settings
Create time 2019-12-11
Comment number 7

Possible solution:
The error message "not enough values to unpack (expected 2, got 1)" is usually caused by an incorrect format of the input. In the existing issue, the error occurred when configuring application settings using a powershell object. The solution was to use the json format inside the json file and provide the correct path to the file in the --settings parameter.

Similarly, in this new issue, the error occurred when running the command "az webapp config connection-string set". The solution might be to check the format of the input and make sure it matches the expected format. It might also be helpful to check the structure of the json file to ensure it has the correct schema.

To set the connection string, you can try running the command with the --settings parameter and providing the correct path to the json file. The content of the json file should be in the following format:

[
{
"name": "ConnectionString",
"slotSetting": false,
"value": "Data Source=tcp:MyServer.database.windows.net,1433;Initial Catalog=MyDatabase;User Id=MyID;Password=MyPassword;"
}
]

Make sure to replace the values with your own connection string information.


Please confirm if this resolves your issue.

Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp.

1 similar comment
Copy link
Contributor

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp.

@seligj95
Copy link
Contributor

I'm unable to repro - I copied your input into CloudShell and was able to set the connection strings.

Please ensure the settings parameter is formatted correctly and escape characters are included where needed based on your shell type.

@sc-draymond
Copy link
Author

I found that I could not use an object to create the string and had to use a string replacement instead. This is showing to not be an issue with the connection-string set function.

$newConnectionString = $ConnectionStringName + '=''Data Source=tcp:' + $DataSource + ',1433;Initial Catalog=' + $SQLDatabase + ';User Id=' + $UserID + ';Password=' + $Password + ';'''

az webapp config connection-string set --connection-string-type SQLServer --name $AppServiceName --resource-group $AppServiceResourceGroupName --subscription $AppServiceSubscriptionID --settings $newConnectionString

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app-service-general Auto-Assign Auto assign by bot Auto-Resolve Auto resolve by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. Possible-Solution Service Attention This issue is responsible by Azure service team. Similar-Issue Web Apps az webapp
Projects
None yet
Development

No branches or pull requests

3 participants