简体   繁体   English

如何在Azure App Service应用程序设置中插入换行符?

[英]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? 在Azure App Service Web应用程序中,如何使用Azure门户在应用程序设置中插入换行符(即\\ n)? Using \\n doesn't appear to get escaped like it would be in C#/json/etc. 使用\\n似乎不会像在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. 我们还在Visual Studio Team Services中使用持续集成,并且不希望在构建过程中不进行文本转换。

I don't think the Portal supports doing this. 我不认为Portal支持这样做。 However, you should be able to do it via API. 但是,您应该可以通过API进行操作。 eg try this: 例如试试这个:

  • Go to Resource Explorer ( https://resources.azure.com/ ) 转到资源浏览器( 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 在您的应用程序下,转到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" 用新行添加应用设置,例如"test": "1234\\n5678"
  • Click POST 点击POST

You can do it through Azure PowerShell task, but just remain newline symbol, the value won't be in multiple lines, for example: 您可以通过Azure PowerShell任务来执行此操作,但只需保留换行符即可,该值不会出现在多行中,例如:

$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 有关更新应用程序设置的文章: 使用PowerShell为Azure App Service应用/更新应用程序设置

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Azure App Service中插入具有1:n关系的实体 - How do I insert entities with a 1:n relationship in Azure App Service 您如何看待Azure应用服务的特定“数据输入”负载? - How do you see the specific “data in” load for an Azure App Service? 如何通过VSTS将Azure WebJob和App部署到同一个App Service? - How do you deploy an Azure WebJob and App to the same App Service via VSTS? 您如何知道您正在访问哪个 Azure 应用服务实例? - How do you know which Azure App Service instance you are accessing? 如何在连接字符串 Azure 发布管道中使用机密 - 使用 Azure 应用服务设置任务 - How you do use Secrets in a Connection String Azure Release Pipeline - Using Azure App Service Settings Task 如何配置不在<appSettings> web.config 的部分? - How do I configure an Azure App Service setting that isn't in the <appSettings> section of the web.config? 如何在 Azure 应用服务上进行线程转储? - How to do a thread dump on Azure App Service? 如何通过 VPN 将 Azure Function(不是应用服务)连接到本地 SQL 服务器? - How do you connect an Azure Function (not an App Service) to an on-premise SQL server via a VPN? 如何从 Azure 应用服务访问外部元数据库配置文件 - How do you access external Metabase configuration file from Azure app service Azure Sql 数据库 - 如何从数据库日志中确定应用服务名称? - Azure Sql Database - how do you determine the app service name from the database logs?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM