简体   繁体   中英

How do you insert a newline in an Azure App Service app setting?

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.

I don't think the Portal supports doing this. However, you should be able to do it via API. eg 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, eg "test": "1234\\n5678"
  • Click POST

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM