Azure.RequestFailedException: 'Service request failed. Status: 404 (The specified blob does not exist.) ErrorCode: BlobNotFound

Viewed 1206

Hello dear developers,

Im facing the issue that I can not read/reach my blob file on my Azure storage account. I use C# as programming language. In the end I want to read my blob file to search for a specific value and check that if its true. Thank you in advance <3

This is how my code looks like.

            //Get a reference to the edc(1.3) container
            string containerName = "edc/rchexport/rch-bu-party-dd/1.3";
            string connectionString = "DefaultEndpointsProtocol=https;AccountName=adlse3.....";
        
        Log.Information($"C# Timer trigger function executed at: {DateTime.Now}");
        BlobContainerClient blobContainerClient = new BlobContainerClient(connectionString, containerName);
        

        //Acces to parquet blob file. Getting the sample structure of the blob to create the final table. 
        string edcRchBuParty = "rchtestdata.parquet";
        BlobClient st5BobClient = blobContainerClient.GetBlobClient(edcRchBuParty);
        var sampleStream = st5BobClient.OpenRead();   **<<<<<<<<< This where the error pops up**.
        var sampleReader = new ParquetReader(sampleStream);

        Table sampleTable = sampleReader.ReadAsTable();
        DataField[] datafields = sampleTable.Schema.GetDataFields();
        Table finalTable = new Table(datafields);
        //looping through the container for getting the blobs and read the file and add the rows to the final table 
        await foreach (BlobItem blobItem in blobContainerClient.GetBlobsAsync())
        {
            if (blobItem.Name.Contains("15b0251556c74fd693ca1f3cb4ce4d6e")) //for testing
            {
                Log.Information("\t" + blobItem.Name);
                BlobClient blobClient = blobContainerClient.GetBlobClient(blobItem.Name);
                var stream = blobClient.OpenRead();  
                var reader = new ParquetReader(stream);
                Table table = reader.ReadAsTable();
                Console.WriteLine("Step 3 : Check");
                foreach (Row row in table)
                {
                    finalTable.Add(row);
                }
                Log.Information(finalTable.Count.ToString());
            }
1 Answers

The issue is with how you are specifying the container name.

Looking at your code, I am guessing your container name is edc and your blob (rchtestdata.parquet) is present in a folder hierarchy like rchexport/rch-bu-party-dd/1.3.

If that's the case, then please change the following line of code:

string containerName = "edc/rchexport/rch-bu-party-dd/1.3";

to

string containerName = "edc";

and change the following line of code:

string edcRchBuParty = "rchtestdata.parquet";

to

string edcRchBuParty = "rchexport/rch-bu-party-dd/1.3/rchtestdata.parquet";

Then you should not get this error.

Related