'How to parse JSON from Azure App Configuration into an strongly typed object
I'm trying to parse JSON from Azure App Configuration into my Azure function but I get null.
Am I doing something wrong?
The Key is "Site" and Value is
{
"SiteUrl": "url",
"TitleXpath": "xpath"
}
Here is the class I'm trying to parse JSON into:
public class SiteData
{
public string SiteUrl { get; set; }
public string TitleXpath { get; set; }
}
In my Azure Function, I get null as a result when I'm trying to parse it into a SiteData obj.
var site = _configuration.GetValue<SiteData>("Site");
However this works:
var site = _configuration.GetValue<string>("Site");
Solution 1:[1]
I managed to solve this problem by:
- Using as Content-Type
application/json - Using
_configuration.GetSection("Site").Get<SiteData>()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | konkri |
