question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az webapp config appsettings set: config key is not correctly generated when JSON settings file contains a hierarchy

See original GitHub issue

I’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:

image

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:closed
  • Created a year ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
StrawnSCcommented, Jul 11, 2022

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

1reaction
StrawnSCcommented, Jul 6, 2022

@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 ....

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JSON content-type for key-values - Azure App Configuration
In this tutorial, you'll learn how to: Create JSON key-values in App Configuration. Import JSON key-values from a JSON file. Export JSON key- ......
Read more >
Unable to configure hierarchical settings with dotnet under IIS
This appsettings.json is used for development purpose. In production mode, we use the Azure Keyvault (as our application is running under Azure) ...
Read more >
az webapp config appsettings set json file
Manage an existing web app's container settings. When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.
Read more >
Web on Servlet Stack - Spring
Individual chapters include Spring MVC, View Technologies, CORS Support, ... the servlet mapping and the location of the DispatcherServlet configuration.
Read more >
Introduction to Azure App Configuration for Developers with ...
Remember #2: NEVER use App Config as a replacement for Azure Key Vault. Credentials are NOT supposed to be stored in here.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found