
Hello Reader,
Today we are going to discuss that how we can use Azure Blob Storage for storing files which we upload from Business Central. So, let’s get started step by Step.
So, we should have an account which is having access of Azure Portal. Now we’ll login with valid Credential in Azure Portal. Once successfully logged in into Portal then move to Storage Accounts.
Here we have already created storage account which as we can be seen below. If you don’t have any storage account in your portal, then you need to create it by clicking on Create.
Now we’ll click on Storage account in which we want to create new container to store files. And then click on Container in left panel to see existing container inside that storage account.
Now we will create a container to store our files into it. For that click on “+ Container” .
Now we’ll move to the al part to create table to store access details of Azure storage Account. So, Lets create table as below.
Now create Page for the same and insert Azure Storage Account access details into it.
Let’s fill all details from Azure portal one by one.
Account Name : Storage Account Name.
Container Name : Container Name which we have created recently.
Shared Access Key : For Shared Access Key Move to Storage Account à Then Click on Access Keys and Copy Key. See below screenshot for reference.
Now Setup should be look like as below screenshot.
Now we need to create one Codeunit to Subscribe Events of Document Attachment Table.
In this process that there are two codeunits which plays an important role while communicating with Azure Storage Portal. One is “ABS Container Client” which is used to create / delete containers. And “ABS Blob Client” is used to insert/fetch files from Blob Storage.
First, we need to Insert the file into Azure Blob Storage whenever user selects file into document Part. For that we will write code on “OnBeforeInsertAttachment” Event of Document Attachment Table using Event Subscriber.
Once file is inserted into Azure Blob Storage Container then we need to remove the Media from Record.
Now we’ll add code to delete the file from Azure Blob Storage Container when user delete from document attachment part. Let’s add the code for same.
Now Build the Project and Publish the changes.
Now let’s move to the Sales Order and Attach document as below.
File has been uploaded successfully in business central. Let’s check the same in Azure Storage Container.
In Container we are able to see the same file which we have attached from Business Central.
Now Let’s try by deleting the same file from Document attachment part.
Here we have checked in Azure Storage Container and file has been deleted from here also.
That’s it.
Happy Reading.
Share your Enterprise concerns/requirements with us on Contact@madhda.com!
Regards,
Madhda Team
Thanking you all.