Business Central and Azure Blob Storage
Last week I was writing that the functionality of "Attachments" in Business Central was storing the files in the database. And I'm not a fan of that. But Kennie pointed me to a new feature in Business Central 2021 wave 2. The Azure Blob Storage in the system app (more details about Azure Blob Storage you can find here: Introduction to Blob (object) storage - Azure Storage | Microsoft Docs).
Well exactly there are two modules of Azure Blob Storage. The first one is the "Azure Storage Service Authorization" this one is for the authentication. There are two types of authentication. The first is the "Shared Key" and the second is the "Shared?Access?Signature". And it is very simple to authorize it through AL code:
On line 33 you can see that you must put the key in the interface "Storage Service Authorization" and that interface you need in the second module. The "Azure Blob Services API".
In there there are two codeunits that are important "ABS?Container?Client" and "ABS?Blob?Client". The first one is for creating / deleting containters. And the second one it for putting / reading files in your Blob Storage.
But when you want to use it you have to use the initialize function first in the codeunit. And there you have the variable authorization needed (in line 34).
So it is a very usefull function for a very quick implementation of Azure Blob Storage in Business Central. So lets make it work with the document attachment??.
First you need to store the file into the Blob Storage when you select a file:
After that we want to delete the file in the media field:
领英推荐
And offcourse when you delete the line, the file on the Blob Storage must also be deleted:
And offcourse you must create an extra button that you download the file from the Blob Storage. Therefor you need to create a page extension on the page "Document?Attachment?Details".
And if you publish it the files aren't stored in your database anymore but on Azure Blob Storage ??.
The source of this little feature you can find on my GitHub Bertverbeek4PS/AzureBlob (github.com) (this source is based on Business Central 2021 wave 2 - preview).
So enjoy the connection with Azure Blob Storage and Business Central ??.
Dynamics 365 Business Central/NAV ERP Consultant
8 个月Hi Bert Verbeek how can i achieve storage to a local network drive instead? its more affordable at least in our situation
Technical Consultant - Microsoft Dynamics 365 Business Central | Expert IT Consultant | Specialist in ERP & E-Commerce
1 年Hi Bert Verbeek can we move table 5062 Attachment to Azure blob storage...
Consultor Dynamics Nav / Business central en Axpo Group
1 年Hi thanks for the example, very clear as allways . I am trying to change the autorization in order to be able to autorizate navision using an Azure application (and application secret) instead of the sharedkey. I think that doing this would be much more safe that sharing this shared key to users. The problem is that I don't find in the authorization codeunits any method to do this... Any Ideas? BR
I got this working flawlessly, but when we go to Make Order from quote (and the quote has an ABS attachment), it errors on this line. (in Document Attachment table OnInsert trigger). Did anyone resolve this? ? ?if not "Document Reference ID".HasValue() then ? ? ? ? ? ? Error(NoDocumentAttachedErr);
Why do I get the error "A call to System.Convert.FromBase64String failed with this message: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters." when I try to attach a file?