[webapp] - az webapp config appsettings is truncating values
ere is the bug I got trying to set an env var. It strips the closing “)”.
PS C:\Users\jafreebe\Desktop\demos\JavaAirLift> az webapp config appsettings set -n freebergjava -g freebergJenkinsDemo --settings SPRING_DATASOURCE_USERNAME="@Microsoft.KeyVault(SecretUri=https://java-app-ke y-vault.vault.azure.net/secrets/POSTGRES-USERNAME/2999981b08ac4e0fa206d0efad0a1a2a)" [ { "name": "JAVA_OPTS", "slotSetting": false, "value": "-XX:StartFlightRecording=disk=true,name=continuous_recording,dumponexit=true,maxsize=1024m,maxage=1d" }, { "name": "WEBSITE_HTTPLOGGING_RETENTION_DAYS", "slotSetting": false, "value": "5" }, { "name": "SPRING_DATASOURCE_USERNAME", "slotSetting": false, "value": "@Microsoft.KeyVault(SecretUri=https://java-app-key-vault.vault.azure.net/secrets/POSTGRES-USERNAME/2999981b08ac4e0fa206d0efad0a1a2a" }, { "name": "SPRING_DATASOURCE_PASSWORD", "slotSetting": false, "value": "@Microsoft.KeyVault(SecretUri=https://java-app-key-vault.vault.azure.net/secrets/POSTGRES-PASSWORD/8e49887cca16454d9da0ff43b44f19b2)" }, { "name": "SPRING_DATASOURCE_URL", "slotSetting": false, "value": "@Microsoft.KeyVault(SecretUri=https://java-app-key-vault.vault.azure.net/secrets/POSTGRES-URL/5d6399007dd8498f930f41f4a0693e53)" } ]
C:\Users\jafreebe\Desktop\demos\JavaAirLift>echo Failed to load python executable. Failed to load python executable.
C:\Users\jafreebe\Desktop\demos\JavaAirLift>exit /b 1
Jason found this bug while demoing Jenkins setup
@btardif / Jason please follow the example here on how to use the app settings command, in general the format is key=value, please don't use the format that Portal uses on the settings blade, that is meant for portal only. This is how to use it az webapp config appsettings set -g MyResourceGroup -n MyUniqueApp --settings WEBSITE_NODE_DEFAULT_VERSION=6.9.1 or az webapp config appsettings set -g MyResourceGroup -n MyUniqueApp --settings mySetting=value @moreSettings.json see the link here for more details https://docs.microsoft.com/en-us/cli/azure/webapp/config/appsettings?view=azure-cli-latest#az-webapp-config-appsettings-set
please try this & respond if you still see the issue. Closing this for now. Thanks!
Sisira,
There is a problem with how Python is interpreting the parentheses and/or quotes.
-
The command fails if there are parentheses. Looks like Python is interpreting it as a tuple and trying to unpack it.
az webapp config appsettings set -n freebergjava -g freebergJenkinsDemo --settings FOOBAR=foobar(12345)not enough values to unpack (expected 2, got 1) Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\knack\cli.py", line 197, in invoke cmd_result = self.invocation.execute(args) File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\commands\__init__.py", line 369, in execute File "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\Lib\site-packages\six.py", line 693, in reraise raise value File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\commands\__init__.py", line 343, in execute File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\commands\__init__.py", line 182, in __call__ File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-core\azure\cli\core\__init__.py", line 436, in default_command_handler File "C:\Users\trdai\AppData\Local\Temp\pip-install-8jgnm5o1\azure-cli-appservice\azure\cli\command_modules\appservice\custom.py", line 148, in update_app_settings ValueError: not enough values to unpack (expected 2, got 1) -
When quoted, the command finishes but silently strips the closing parentheses.
az webapp config appsettings set -n freebergjava -g freebergJenkinsDemo --settings FOOBAR="foobar(12345)".[ { "name": "JAVA_OPTS", "slotSetting": false, "value": "-XX:StartFlightRecording=disk=true,name=continuous_recording,dumponexit=true,maxsize=1024m,maxage=1d" }, { "name": "FOOBAR", "slotSetting": false, "value": "foobar(12345" } ] C:\Users\jafreebe>echo Failed to load python executable. Failed to load python executable. C:\Users\jafreebe>exit /b 1There is some weird output about the python executable and
exit \b 1. (I did not provide those commands) -
I had to provide my argument in quotes because otherwise Powershell tries to interpret the quoted value as a cmdlet. Exaple output without quotes:
az webapp config appsettings set -n freebergjava -g freebergJenkinsDemo --settings [email protected](SecretUri=https://java-app-key-vault.vault.azure.net/secrets/POSTGRES-USERNAME/2999981b08ac4e0fa206d0efad0a1a2a) SecretUri=https://java-app-key-vault.vault.azure.net/secrets/POSTGRES-USERNAME/2999981b08ac4e0fa206d0efad0a1a2a : The term 'SecretUri=https://java-app-key-vault.vault.azure.net/secrets/POSTGRES-USERNAME/2999981b08ac4e0fa206d0efad0a1a2a' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:131 + ... ft.KeyVault(SecretUri=https://java-app-key-vault.vault.azure.net/secr ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (SecretUri=https...206d0efad0a1a2a:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
I'm hitting this issue too and found a decent work around. The az command can be run using cmd from powershell.
The exact syntax is pretty important it seems:
$mySetting = "[email protected](SecretUri=foobar)"
cmd /c "az functionapp config appsettings set --name $myFunction --resource-group $myResourceGroup --settings `"$mySetting`""
@JasonFreeberg and @btardif when you repro the error - is this when you are running in Jenkins - which uses Powershell terminal - this seems like an issue with how different terminals are parsing the object before passing it to CLI. @calvinsID has tried to repro this and & seeing weird behavior with different terminals if the characters aren't escaped correctly, but once the recommended syntax for the terminals is followed we can save the settings correctly. @calvinsID can you share the examples of the formatted object that works for you on PS/Terminal/CMD/Bash? Thanks!
Powershell: --settings '"FOOBAR=foobar(12345)"' or --settings 'FOOBAR=foobar^^^(12345^^^)'
CMD: --settings "FOOBAR=foobar(12345)"
Bash: --settings "FOOBAR=foobar(12345)"
Please let me know if those work for you
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @antcp, @AzureAppServiceCLI.
@panchagnula, @calvinsID
So good news, I'm not able to repro the issue any more. I used the Cloud Shell, which I'm assuming is using the latest PowerShell and Azure CLI (7.0.0 and 2.4.0). I was able to set the "foobar(12345)" variable without escaping the parentheses or quotes:
az webapp config appsettings set -n freeberg-build -g freebergDemo --settings FOO="foobar=(foobar)"
And that set the app setting as expected. The example with the Key Vault reference also worked as expected. I think we can safely assume there's been an updated to the CLI or PowerShell in the last year that fixed this.
Closing this based on @JasonFreeberg comments
Azure CLI version 2.11.0 gives me still the issue, in Powershell and Powershell Core (in Functions for me).
Using the ^ symbols are preventing the python error but I don't like the syntax that much tbh.
This also works for me from Powershell:
az functionapp config appsettings set -n $FunctionApp --settings """[email protected](SecretUri=$KeyVaultIdTestSecret)"""
But when I run the same command (and also single double quoted) from Azure Portal Command Line with Powershell the command succeeds but Function Configuration fails to load (not the case with local PS execution), this can/is probably be another bug:

Still having the same issue with az cli 2.15.0
> az webapp config appsettings set --resource-group $resourceGroup --name $appName --settings FOO="foobar=(foobar)"
[
{
"name": "FOO",
"slotSetting": false,
"value": "foobar=(foobar"
}
]
> echo Failed to load python executable.
Failed to load python executable.
> exit /b 1
I'm actually running in the same error.
I'm executing this command in an AzureCLI@2 task in a yaml pipeline which runs on a windows-2022 hosted agent with scripttype pscore.
Version of Azure CLI is 2.198.0
I ran into the error which says 'not enough values to unpack', and I also ran in the situation where the last ) was truncated from my config-value (which is a KeyVault secret reference).
Relevant parts of my script look like this:
$b2cClientSecretSettingName = "$(Authentication.AuthenticationApi.AzureB2C_ClientSecret.SettingName)"
$b2cClientSecretSettingValue = "@Microsoft.KeyVault(SecretUri=$b2cClientSecretUri)"
az webapp config appsettings set -n $(Authentication.AuthenticationApi.Name) -g $(Authentication.ResourceGroup.Name) --settings $b2cClientSecretSettingName="$b2cClientSecretSettingValue"
Might this issue be somewhat related to this ? https://github.com/Azure/azure-cli/issues/17804
I'm actually running in the same error. I'm executing this command in an AzureCLI@2 task in a yaml pipeline which runs on a windows-2022 hosted agent with scripttype pscore.
Version of Azure CLI is 2.198.0
I ran into the error which says 'not enough values to unpack', and I also ran in the situation where the last ) was truncated from my config-value (which is a KeyVault secret reference).
Relevant parts of my script look like this:
$b2cClientSecretSettingName = "$(Authentication.AuthenticationApi.AzureB2C_ClientSecret.SettingName)" $b2cClientSecretSettingValue = "@Microsoft.KeyVault(SecretUri=$b2cClientSecretUri)" az webapp config appsettings set -n $(Authentication.AuthenticationApi.Name) -g $(Authentication.ResourceGroup.Name) --settings $b2cClientSecretSettingName="$b2cClientSecretSettingValue"
I have worked around this by running this task on a ubuntu hosted agent instead of on a windows hosted agent in Azure Devops.
Also seeing the same issue trying to add a keyvault reference using the CLI, my version is:
"azure-cli": "2.37.0",
"azure-cli-core": "2.37.0",
Only way I was able to do it was using this method:
I'm hitting this issue too and found a decent work around. The az command can be run using cmd from powershell.
The exact syntax is pretty important it seems:
$mySetting = "[email protected](SecretUri=foobar)" cmd /c "az functionapp config appsettings set --name $myFunction --resource-group $myResourceGroup --settings `"$mySetting`""