5

In an Azure App Service web app, how do you insert a newline character (ie. \n) into an app setting using the Azure portal? Using \n doesn't appear to get escaped like it would be in C#/json/etc.

If it's not possible, what is the recommended way to configure long strings of text to pass into an app? We're also using continuous integration in Visual Studio Team Services and would prefer to not get into text transformations during the build process.

2
  • 2
    Do you solve this issue? Commented May 7, 2018 at 5:40
  • 1
    Azure application settings trim spaces automatically, so if you have spaces / newlines that need to be there as prefix or suffix with pipeline deployment, you will need to find an alternative solution.
    – Pui Ho Lam
    Commented Aug 30, 2023 at 16:07

2 Answers 2

11

I don't think the Portal supports doing this. However, you should be able to do it via API. e.g. try this:

  • Go to Resource Explorer (https://resources.azure.com/)
  • Find your app (aka website), either using search box or by finding it in the tree
  • Under your app, go to config/appsettings
  • Click Edit (you may need to switch to Read/Write mode at the top)
  • Add an App Setting with a new line, e.g. "test": "1234\n5678"
  • Click POST
1
  • 1
    This is brilliant, didn't know about the Resource Explorer. Can confirm this approach doesn't escape newline characters in settings. Commented May 16, 2019 at 8:51
1

You can do it through Azure PowerShell task, but just remain newline symbol, the value won’t be in multiple lines, for example:

$webAppName="XXX"
$resourceGroupName="XXX"
$newAppSettings =@{"newSetting01"="newValue01";"newSetting02"="t1\nt2\n123456"}
Set-AzureRmWebApp -AppSettings $newAppSettings -Name $webAppName -ResourceGroupName $resourceGroupName

There is an article about update application setting: Apply / Update application settings for Azure App Service using PowerShell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.