So I have this powershell script:
$rawJsonData = az appconfig kv list --connection-string $env:APP_CONFIG_CONNECTION_STRING --fields key value
$keyValuePairs = $rawJsonData | ConvertFrom-Json
This works completely fine on my local powershell, but when I run it on my azure app service's docker container (through Kudu ssh), I get the following error:
ConvertFrom-Json : Invalid JSON primitive: _.
Here is an example of the structure I get:
[
{
"key": "any_key",
"value": "any_value"
},
{
"key": "any_key",
"value": "any_value"
}
]
I have verified that the object I receive on my local and in the azure powershell are the exact same. I have also verified that this occurs regardless of the key value fields (happens with both if I just specifiy one or the other alone).
It seems that on the azure side, it doesn't like an underscore character "_" that exists in my object, but I find that odd if it works on my local powershell. Any help to further debug this or resolve this would be greatly appreciated.
I have tried converting it to a string first with .ToString()
I have also tried attaching --output json
I have tried Get-Content -Raw...
I have tried Invoke-WebRequest...
Okay guys, I found the issue. It seems that when I run the above in the Azure powershell environment it returns Hyper-v text and then the json, so my actual out put was:
The way it was resolved was by exporting the json data to a temp file (app_config.json) and then reading that back in: