[英]updating web config file using azure cli task
I am trying to update my web config file using the azure powershell task in azure build pipeline.我正在尝试使用 azure powershell 任务在 ZCF04A02E37B774C5971C 管道中更新我的 web 配置文件。 the following is the script i use.
以下是我使用的脚本。
$storageConectionString="DefaultEndpointsProtocol=https;AccountName="+$storageAccountName+";AccountKey="+$value+";EndpointSuffix=core.windows.net"
$sqlConnectionString ="server=tcp:"+$sqlServerName+";database="+$databasename+";UID=AnyString;Authentication=Active Directory Interactive"
#file path in azure repo
$configFilePath = "$visualStudioFolder/NRMAPP//NRMAPP/NRMAPP/Web.config"
$myXML = [Xml] (Get-Content $configFilePath)
$sqlConnectionObj = $myXML.configuration.connectionStrings.add
$sqlConnectionObj.connectionString = $sqlConnectionString
write-output $sqlConnectionObj
$storageConnectionObj = $myXML.configuration.appSettings.add | where {$_.Key -eq "StorageConnectionString" }
$storageConnectionObj.value = $storageConectionString
write-output $storageConnectionObj
$myXML.Save($configFilePath)
The build pipeline runs successfully but not making the changes to the config file in azure repo.构建管道成功运行,但未对 azure 存储库中的配置文件进行更改。 Any help is appreciated thanks in advance.
提前感谢任何帮助。
The code changes made in the pipeline cannot be reflected in the azure repo.管道中所做的代码更改无法反映在 azure 存储库中。 Because the pipelines always clone your repo to the local default working folder on the agent machine.
因为管道总是将您的存储库克隆到代理机器上的本地默认工作文件夹。 And all the changes are done with the local files cloned from your azure repo on the agent machine.
并且所有更改都是使用从代理机器上的 azure 存储库克隆的本地文件完成的。
If you want to push the changes to your azure repo.如果您想将更改推送到 azure 存储库。 You may have to use another scrip task to run the git commands.
您可能必须使用另一个脚本任务来运行 git 命令。 Please check out below scripts:
请查看以下脚本:
- powershell: |
git config --global user.email "your@email.com"
git config --global user.name "yourUsername"
#git add filename.ext
git add .
git commit -m "message"
git push https://$(System.AccessToken)@dev.azure.com/yourOrg/yourProj/_git/repoName HEAD:master -q
There's no need to write this yourself.这个没必要自己写。 The app service deployment task supports deployment-time XML configuration transform via
parameters.xml
to define transforms and setparameters.xml
to define values. 应用服务部署任务通过
parameters.xml
支持部署时 XML 配置转换。xml 定义转换和设置参数setparameters.xml
定义值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.