I am trying to update my web config file using the azure powershell task in azure build pipeline. 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. Any help is appreciated thanks in advance.