I got stuck with this setup on Azure release variable using the classic setting. With .net i can assign the value like I tried below and it didn't work. 'AppNamespace1.Domain1.Category1.Configuration'.Endpoints.ProcessorEndpoint.EndpointURL and AppNamespace1.Domain1.Category1.Configuration.Endpoints.ProcessorEndpoint.EndpointURL
My appsettings.json look like this and I am not allowed to change "AppNamespace1.Domain1.Category1.Configuration".
appsettings.json
{
"AppNamespace1.Domain1.Category1.Configuration": {
"Endpoints": {
"ProcessorEndpoint": {
"EndpointURL": "http://localhost:50576/RequestExecutor/",
"ClientKey": "DefaultClient"
},
}
}
Expected result
"EndpointURL": "NEW VALUE HERE"
Below is a sample to update the value of EndpointURL
in the appsettings.json
file.
You can try to run the PowerShell script mentioned here in your pipeline.
appsettings.json
{
"AppNamespace1.Domain1.Category1.Configuration": {
"Endpoints": {
"ProcessorEndpoint": {
"EndpointURL": "http://the/old/url/",
"ClientKey": "DefaultClient"
}
}
}
}
update-json.ps1
: PowerShell script to update the JSON file.$newURL = "http://the/new/url/"
# Read the content of appsettings.json file.
Write-Host "Read the content of appsettings.json file."
$jsonContent = Get-Content .\appsettings.json -Raw | ConvertFrom-Json
Write-Host ($jsonContent | ConvertTo-Json -Depth 100)
# Get the old EndpointURL.
Write-Host "Get the old EndpointURL."
$oldURL = $jsonContent.'AppNamespace1.Domain1.Category1.Configuration'.Endpoints.ProcessorEndpoint.EndpointURL
Write-Host $oldURL
Write-Host "=============================================="
# Update the EndpointURL to the new one.
Write-Host "Update the EndpointURL to the new one."
$jsonContent.'AppNamespace1.Domain1.Category1.Configuration'.Endpoints.ProcessorEndpoint.EndpointURL = $newURL
$jsonContent | ConvertTo-Json -Depth 100 | Out-File .\appsettings.json
Write-Host "=============================================="
# Read the content of appsettings.json file after updating the EndpointURL.
Write-Host "Read the new content of appsettings.json file."
$jsonContentNew = Get-Content .\appsettings.json -Raw | ConvertFrom-Json
Write-Host ($jsonContentNew | ConvertTo-Json -Depth 100)
# Get the new EndpointURL.
Write-Host "Get the new EndpointURL."
$readNewURL = $jsonContentNew.'AppNamespace1.Domain1.Category1.Configuration'.Endpoints.ProcessorEndpoint.EndpointURL
Write-Host $readNewURL