az webapp config appsettings set: config key is not correctly generated when JSON settings file contains a hierarchy
See original GitHub issueI’m running an Azure CLI command to update the configuration for a WebApp in Azure.
This command is executed via a DevOps pipeline, through an AzureCLI@2
task (scripttype=pscore), running on a Linux agent (ubuntu-20.04).
The version of AzureCLI running on that agent: 2.198.0
Related command I execute this code from the pipeline:
$tempFile = Join-Path -Path $(Agent.TempDirectory) -ChildPath "settingsfile"
Out-File -FilePath $tempFile -InputObject "{'ClientSettings': {'AzureB2C': {'ClientSecretSecretUri': '$b2cClientSecretSettingValue'}}}"
az webapp config appsettings set -n $myApp -g $myResourceGroup --settings @$tempFile
I would expect that a config value is added to my webapp, where the key would be: ClientSettings:AzureB2C:ClientSecretUri
.
However, the setting’s key is just ClientSettings
and the value contains the remainder of the JSON, like this:
When I run similar code, but with a JSON file that only contains a 2-level hierarchy, the same problem occurs.
PS: I use this method as a workaround, since executing the command like this:
az webapp config appsettings set -n $myApp -g $myResourceGroup --settings "ClientSettings:AzureB2C:ClientSecret"="@Microsoft.KeyVault(SecretUri=....)"
also results in errors, as described here: https://github.com/Azure/azure-cli/issues/10066#issuecomment-516072988
Issue Analytics
- State:
- Created a year ago
- Comments:13 (11 by maintainers)
Top GitHub Comments
Sorry, we don’t currently have any plans to change how we interpret JSON files here. I would recommend preprocessing your input if you would like nested JSON to be interpreted in the way you describe above
@RakeshMohanMSFT, yes this is working as expected. We don’t traverse nested json when you pass a file in. It’s assumed to be in the format
{key1: value1, key2: value2, ...}
, just like if you you called the command with--settings key1=value1 key2=value2 ...
.