I get a QueryResponse.Data returning the following data in table format with two columns "type" and name":
Content: {"columns": [{"name": "type","type": "string"},{"name": "name","type": "string"}],"rows": [["microsoft.apimanagement/service","api-management-name1"],...]
The final query will have much more fields and might be dynamically adjusted? What is a scalable way to convert to a csv file?
// Table or ObjectArray
request.Options = new QueryRequestOptions() { Top = 50, ResultFormat = ResultFormat.Table };
QueryResponse response = argClient.Resources(request);
log.LogInformation("Count: " + response.Count);
List<object> results = new List<object>();
if (response.Count > 0)
{
// Continue till SkipToken is null
while (!string.IsNullOrWhiteSpace(response.SkipToken))
{
// Update request with new skip token returned from response
request.Options.SkipToken = response.SkipToken;
// Send query with SkipToken to the ResourceGraphClient and get response
response = argClient.Resources(request);
log.LogInformation("Skip: " + response.SkipToken);
//todo narrow down rows
results.Add(response.Data);
}
}
log.LogInformation("Content count : " + results.Count);
foreach (var row in results)
{
log.LogInformation("Content: " + row.ToString());
}
Thanks!
Edit: I seem to be close with log.LogInformation(res["rows"]) resulting in the following:
[["microsoft.apimanagement/service","name1"],["microsoft.apimanagement/service","name2"],["microsoft.apimanagement/service","name3"],["microsoft.apimanagement/service","name4"]
...]
However res["rows"].toString() returns 'JToken' does not contain a definition for 'toString' and no accessible extension method 'toString' accepting a first argument of type 'JToken' could be found (are you missing a using directive or an assembly reference?) Any possibility to get straight to csv? If not, what is the recommended way to automate Azure Resource Graph csv creation? Writing a console application?