Skip to main content

Notifications

Dynamics 365 general forum

Retrieving .pdf files from Azure Blob using C# .NET Console App

Posted on by 105

Hi All,

We have installed the Azure Attachment management solution and moved over Annotations(notes) to the blob container on Azure.

There is now a requirement, wherein we need to create a console app, which will extract these pdf files from blob, zip them and ftp them over to the clients.

I can use zip archive to carry out the zip function in the code, but, I'm not sure about how to retrieve the .pdf files from the container in Azure using the console app.

I'm looking to understand how to query the blob database on Azure, retrieve the file and process it in C# code.

Can you please advise, or share a code sample , where a blob is being retrieved using the file name/GUID(not sure if the filename is the GUID on Azure).

An example of one of our files, which I see in the blob notes container is as(GUID + filename):

017ed429-5460-e711-814a-e0071b668681_01 Cash Cards 2017- $200.pdf

Any help is appreciated.

Thanks

  • Toly Rogers Profile Picture
    Toly Rogers 105 on at
    RE: Retrieving .pdf files from Azure Blob using C# .NET Console App

    Hi Ravi,

    Thanks for the response to my query.

    I've written the below logic to retrieve the .pdf files from blob:

                            var containerName = "notes";

                           CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Microsoft.Azure.CloudConfigurationManager.GetSetting("StorageConnectionString"));

                           CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                           CloudBlobContainer container = blobClient.GetContainerReference(containerName);

                           string _blobfilename = (blobnote.Attributes["annotationid"].ToString() + "_" + blobnote.Attributes["filename"].ToString());

                           CloudBlockBlob blockBlob = container.GetBlockBlobReference(_blobfilename);

    The issue is I need to return the blockBlob back as Entity. Do you know how that can be achieved ?

    Thanks !!

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Retrieving .pdf files from Azure Blob using C# .NET Console App

    Hi,

    Try this blog: community.dynamics.com/.../upload-and-download-files-in-azure-blob-using-c

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans