Hello,
I have created an Azure Function which is of Blob Trigger type . It will read a data from blob ( having invalid format of json ) and will convert it to a valid json file. I am trying to run this function but it is showing "Azure.RequestFailedException" . Can anybody suggest any solution to get rid of this exception. Am i missing anything like permissions etc in azure portal.
This is my function code -
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace ConBlobJSON
{
public class Function1
{
[FunctionName("Function1")]
public void Run([BlobTrigger("powerbi-admin/AD_User_data/{AD_User}", Connection = "AzureWebJobsStorage")]Stream myBlob, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name: \n Size: {myBlob.Length} Bytes");
var serializer = new JsonSerializer();
try
{
using (var sr = new StreamReader(myBlob))
using (var jsonTextReader = new JsonTextReader(sr))
{
dynamic data = serializer.Deserialize(jsonTextReader);
var newString = "";
int i = 0;
foreach (var res in data)
{
if (res != null)
{
if (i == 0)
newString = Convert.ToString(res);
else
newString = newString + "," + Convert.ToString(res);
}
i++;
}
newString = "[" + newString + "]";
log.LogInformation($"{newString}");
//Console.WriteLine(newString);
// Do something with person.
}
}
catch (Exception ex)
{
log.LogError(ex.Message);
}
}
}
}
This is my connection setting
This is the exception