Getting "Azure.RequestFailedException" while running Azure Function

Amar Agnihotri 891 Reputation points
2022-08-17T09:25:09.707+00:00

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
231869-image.png

This is the exception
231946-image.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,228 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,424 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruno Lucas 4,411 Reputation points MVP
    2022-08-17T11:08:32.11+00:00

    Hi @Amar Agnihotri

    I tried to reproduce the problem but didn't get this error.
    Found this post that post commenting on similar issue but the code works and throws exception for this user:
    https://github.com/Azure/azure-sdk-for-net/issues/18209

    What version of .Net and Microsoft.Azure.WebJobs.Extensions.Storage are you using?

    1 person found this answer helpful.