【发布时间】:2021-04-08 19:49:37
【问题描述】:
我们目前有以下 Web.Release.config 文件,可在部署时转换 Web.config。
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
<elmah>
<errorLog xdt:Transform="Remove" />
<errorMail xdt:Transform="Remove" />
<errorMail xdt:Transform="Insert" from="reports@companyxyz.com" to="a23cv@companyxyzteam.slack.com" subject="Dashboard Error" async="true" smtpPort="587" smtpServer="smtp.sendgrid.net" userName="apikey" password="password123" />
</elmah>
</configuration>
如您所见,配置文件包含敏感信息,例如password。
管道工件包含脚本、内容、捆绑包以及与此问题最相关的 Web.Debug.config、Web.Release.config 和 Web.config:
工件发布后,发布管道触发 Azure App Service 任务部署:
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy Azure App Service'
inputs:
azureSubscription: '$(Parameters.ConnectedServiceName)'
appType: '$(Parameters.WebAppKind)'
WebAppName: '$(Parameters.WebAppName)'
enableCustomDeployment: true
TakeAppOfflineFlag: false
RenameFilesFlag: false
enableXmlTransform: true
我们希望将它们存储为变量,可能在发布管道中(可能创建一个elmah 组包含这些属性/值)并使用这些变量来转换Web.config 文件。
当然,我们仍然希望出现其他 XML 转换设置,例如 <system.web>,但我们希望使用变量而不是 XML 文件来转换 <elmah> 中的属性。
我们怎样才能做到这一点?
我知道如何创建变量,但我不确定如何或是否可以使用变量而不是 Web.Debug.config 或 Web.Release.config 来转换 Web.config 文件
是否有可以做到这一点的设置/任务?
【问题讨论】:
-
要正确处理密码,您可能会考虑更好的方法,例如this
-
@LexLi 很好的建议,但 elmah 只是一个用例。我们还有其他需要将键/值存储在其他地方并对其进行转换,所以我仍然希望 Azure Devops 中的解决方案
标签: azure-devops web-config azure-pipelines-release-pipeline azure-pipelines-build-task azure-pipelines-tasks