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 functionapp config appsettings set for multiple config not working from 2.40 #23887

Closed
kornbo2-dev opened this issue Sep 14, 2022 · 16 comments
Assignees
Labels
Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. CXP Attention This issue is handled by CXP team. Functions az functionapp needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@kornbo2-dev
Copy link

az functionapp config appsettings set command for multiple config not working from 2.40

https://docs.microsoft.com/en-us/cli/azure/functionapp/config/appsettings?view=azure-cli-latest

This use to work before 2.40:
az functionapp config appsettings set --name $FunctionAppName --resource-group $ResourceGroupName --slot-settings "AppConfig1=test" "AppConfig2=test2"

now still works, but all the values will be stored in AppConfig1

AppConfig1=test AppConfig2=test2

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot CXP Attention This issue is handled by CXP team. Functions az functionapp labels Sep 14, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 14, 2022

route to CXP team

@RakeshMohanMSFT RakeshMohanMSFT self-assigned this Sep 14, 2022
@RakeshMohanMSFT
Copy link
Contributor

@kornbo2-dev Thank you for reaching out, we are looking into it.

@kornbo2-dev
Copy link
Author

@kornbo2-dev Thank you for reaching out, we are looking into it.

Thank you. This is causing all our deployments to fail as devOps is running the scripts using 2.40. Let us know if there is a workaround. thank you.

@kornbo2-dev
Copy link
Author

we are actually using this one.... via a variable and it was working....

$FunctionAppConfigCreate = @("AppConfig1=test" "AppConfig2=test2")

az functionapp config appsettings set --name $FunctionAppName --resource-group $ResourceGroupName --slot-settings $FunctionAppConfigCreate

@RakeshMohanMSFT
Copy link
Contributor

@kornbo2-dev We are unable to reproduce this issue at our end with 2.40.0, please see below screenshots
image
image

@RakeshMohanMSFT RakeshMohanMSFT added the needs-author-feedback More information is needed from author to address the issue. label Sep 15, 2022
@kornbo2-dev
Copy link
Author

kornbo2-dev commented Sep 15, 2022

@kornbo2-dev We are unable to reproduce this issue at our end with 2.40.0, please see below screenshots image image

We are actually putting it on a variable, apologies... can you try below? thanks

$FunctionAppConfigCreate = @("AppConfig1=test", "AppConfig2=test2")

az functionapp config appsettings set --name $FunctionAppName --resource-group $ResourceGroupName --slot-settings $FunctionAppConfigCreate

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Sep 15, 2022
@rick-hayek
Copy link

similar issue happens for
az webapp config appsettings set

@RakeshMohanMSFT
Copy link
Contributor

@StrawnSC / @panchagnula is this a regression?

@runefa
Copy link
Contributor

runefa commented Sep 15, 2022

This is not a regression. This is failing due to the $FunctionAppConfigCreate powershell var. When a powershell string array is passed, it is automatically converted to a string with quotation delimiters, so you end up passing "AppConfig1=test AppConfig2=test2" instead of "AppConfig1=test" "AppConfig2=test2". The config appsettings --slot-settings requires separate strings delimited by spaces, and since a single string is passed, this command won't work.

@kornbo2-dev
Copy link
Author

kornbo2-dev commented Sep 15, 2022

This is not a regression. This is failing due to the $FunctionAppConfigCreate powershell var. When a powershell string array is passed, it is automatically converted to a string with quotation delimiters, so you end up passing "AppConfig1=test AppConfig2=test2" instead of "AppConfig1=test" "AppConfig2=test2". The config appsettings --slot-settings requires separate strings delimited by spaces, and since a single string is passed, this command won't work.

this used to work before in all our pipelines using 2.39

anyway, we have found a workaround not to use an array variable as we have over 50+ config that we need to pass...

@panchagnula
Copy link
Contributor

This is not a regression. This is failing due to the $FunctionAppConfigCreate powershell var. When a powershell string array is passed, it is automatically converted to a string with quotation delimiters, so you end up passing "AppConfig1=test AppConfig2=test2" instead of "AppConfig1=test" "AppConfig2=test2". The config appsettings --slot-settings requires separate strings delimited by spaces, and since a single string is passed, this command won't work.

this used to work before in all our pipelines using 2.39

anyway, we have found a workaround not to use an array variable as we have over 50+ config that we need to pass...

There is no changes on specifically to this command that can explain any regressions. Glad you found a work around.

@jiasli
Copy link
Member

jiasli commented Sep 19, 2022

Duplicate of #23797

@jiasli jiasli marked this as a duplicate of #23797 Sep 19, 2022
@sreagleeye
Copy link

@panchagnula I don't think this issue should be closed. There is something weird here.

All of our MS Hosted pipelines that use the Azure CLI task with PowerShell Core started to break after they upgraded their image to use Azure CLI version 2.40. I have narrowed the issue down to using to the az webapp config appsettings set command with PowerShell string variable.

The following works:

az webapp config appsettings set --settings "Key1=val" "Key2=other val" --name $resourceName --resource-group $resourceGroupName --subscription $subscription

The following throws an error (due to the space in the value of Key2):

$settingsPairs = '"Key1=val" "Key2=other val"'
az webapp config appsettings set --settings $settingsPairs --name $resourceName --resource-group $resourceGroupName --subscription $subscription
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\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 557, in shell_safe_json_parse
  File "json\__init__.py", line 359, 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)

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

Traceback (most recent call last):
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 392, in update_app_settings
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 583, in shell_safe_json_parse
azure.cli.core.azclierror.InvalidArgumentValueError: Failed to parse string as JSON:
val
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 "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/appservice/custom.py", line 403, in update_app_settings
ValueError: not enough values to unpack (expected 2, got 1)

As others have mentioned, I have been using this command (within Azure pipelines as well as from my local computer's PowerShell) successfully previously. It's only when I upgraded my local Azure CLI to version 2.40 that I started to get this error.

@panchagnula
Copy link
Contributor

@sreagleeye use the parent bug for updates/ discussions. As mentioned there were no changes specific to this command.

@RakeshMohanMSFT
Copy link
Contributor

@sreagleeye Please see the explanation and solution at #23797 (comment)

@sreagleeye
Copy link

@RakeshMohanMSFT Thank you for that update. I had not seen that comment/solution. This is an issue across all commands that use array parameters. Using splatting as that comment specifies has fixed the issue.

@RakeshMohanMSFT RakeshMohanMSFT added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. CXP Attention This issue is handled by CXP team. Functions az functionapp needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

8 participants