Reputation: 11
I have the following file ocelot.json and I want to change the Host object of each route configured inside the file through a variable. I want to change the localhost to the correct hostname through a variable.
"Routes": [
//Parámetricas
{
"UpstreamPathTemplate": "/api/ClasificacionEquipo",
"UpstreamHttpMethod": [ "GET" ],
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 19007
}
],
"DownstreamPathTemplate": "/api/ClasificacionEquipo",
"FileCacheOptions": {
"TtlSeconds": 3600,
"Region": "parametricas"
}
},
{
"UpstreamPathTemplate": "/api/ClasificacionEquipo/{id}",
"UpstreamHttpMethod": [ "GET" ],
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 19007
}
],
"DownstreamPathTemplate": "/api/ClasificacionEquipo/{id}",
"FileCacheOptions": {
"TtlSeconds": 300,
"Region": "parametricas"
}
}
]
I create the following variable but it doesn't take me the change: Routes.DownstreamHostAndPorts.Host.
I have also tried as follows: Routes.*.DownstreamHostAndPorts.0.Host
And it hasn't worked for me
Upvotes: 1
Views: 556
Reputation: 736
The answer is
Routes.0.DownstreamHostAndPorts.0.Host
Routes.0.DownstreamHostAndPorts.1.Host
Routes.1.DownstreamHostAndPorts.0.Host
Routes.1.DownstreamHostAndPorts.1.Host
Upvotes: 0
Reputation: 5250
If you want to do file transformation of JSON files in ADO we have the FileTransform@1 task
- task: FileTransform@1
displayName: Transform Json File
inputs:
folderPath: '$(System.DefaultWorkingDirectory)/<path-to-your-file>'
fileType: 'json'
targetFiles: '<your-file-name>.json'
More info on this https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/file-transform?view=azure-devops
Upvotes: 0