使用 azure cli 任务更新 web 配置文件
updating web config file using azure cli task
我正在尝试使用 azure 构建管道中的 azure powershell 任务更新我的 Web 配置文件。以下是我使用的脚本。
$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)
构建管道成功运行但未对 azure 存储库中的配置文件进行更改。提前感谢任何帮助。
没必要自己写。 app service deployment task 支持部署时 XML 配置转换,通过 parameters.xml
定义转换和 setparameters.xml
定义值。
- 构建管道 运行 成功但未对 azure 存储库中的配置文件进行更改。
在管道中所做的代码更改无法反映在 azure 存储库中。因为管道总是将您的存储库克隆到代理计算机上的本地默认工作文件夹。所有更改都是使用从代理计算机上的 azure 存储库克隆的本地文件完成的。
如果您想将更改推送到您的 Azure 存储库。您可能需要使用另一个脚本任务来执行 运行 git 命令。请查看以下脚本:
- 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
- 市场上还有可用的扩展任务,您可以直接使用它们来更新您的网络配置。例如 Magic Chunks task. You can check out the example in this thread。
我正在尝试使用 azure 构建管道中的 azure powershell 任务更新我的 Web 配置文件。以下是我使用的脚本。
$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)
构建管道成功运行但未对 azure 存储库中的配置文件进行更改。提前感谢任何帮助。
没必要自己写。 app service deployment task 支持部署时 XML 配置转换,通过 parameters.xml
定义转换和 setparameters.xml
定义值。
- 构建管道 运行 成功但未对 azure 存储库中的配置文件进行更改。
在管道中所做的代码更改无法反映在 azure 存储库中。因为管道总是将您的存储库克隆到代理计算机上的本地默认工作文件夹。所有更改都是使用从代理计算机上的 azure 存储库克隆的本地文件完成的。
如果您想将更改推送到您的 Azure 存储库。您可能需要使用另一个脚本任务来执行 运行 git 命令。请查看以下脚本:
- 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
- 市场上还有可用的扩展任务,您可以直接使用它们来更新您的网络配置。例如 Magic Chunks task. You can check out the example in this thread。