Business Central and Azure Blob Storage

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:

Geen alternatieve tekst opgegeven voor deze afbeelding

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:

Geen alternatieve tekst opgegeven voor deze afbeelding

After that we want to delete the file in the media field:

Geen alternatieve tekst opgegeven voor deze afbeelding

And offcourse when you delete the line, the file on the Blob Storage must also be deleted:

Geen alternatieve tekst opgegeven voor deze afbeelding

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 ??.

Geen alternatieve tekst opgegeven voor deze afbeelding
Geen alternatieve tekst opgegeven voor deze afbeelding

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 ??.

Ralph Osoti

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

回复
Malith Ranawaka

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...

回复
Santiago Sans Villa

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?

回复

要查看或添加评论,请登录

Bert Verbeek的更多文章

  • From Data Archive to Azure Data Lake

    From Data Archive to Azure Data Lake

    Last time a write an article about the newly released extension "Data Archive" (Data Archive in Business Central –…

    1 条评论
  • Business Central Performance Toolkit changes in BC20

    Business Central Performance Toolkit changes in BC20

    Microsoft has showed their release plans for Business Central 2022 wave 1. Unfortunately there is nothing to show about…

    5 条评论
  • Performance Toolkit in Business Central - Part 3

    Performance Toolkit in Business Central - Part 3

    This last blog about the performance toolkit I will talk about how you can run it but also how you can extract te…

    1 条评论
  • Performance Toolkit in Business Central - Part 2

    Performance Toolkit in Business Central - Part 2

    In this second part we are going to look into how you can create the test codeunits. Part 1 you can lookup here:…

    11 条评论
  • Performance Toolkit in Business Central - Part 1

    Performance Toolkit in Business Central - Part 1

    This blog I want to write a long time ago. But now it is finally there (for part 1).

    1 条评论
  • The journey is ended for the mail merge story in Business Central

    The journey is ended for the mail merge story in Business Central

    Well maybe a very strange title ??. But let me clarify this.

    3 条评论
  • Business Central and MS Excel

    Business Central and MS Excel

    The most financial users in a company are very keen in MS Excel. I have seen the most impresive worksheet.

    2 条评论
  • Business Central and Images

    Business Central and Images

    Last week I did a compare of the Business Central 18 system app and the new Business Central 19 system app. And there…

    2 条评论
  • SharePoint Online and Oauth2 in Business Central OnPrem

    SharePoint Online and Oauth2 in Business Central OnPrem

    This week I was struggling with an OnPrem installation of Business Central, Oauth2 and SharePoint Online. It was hard…

    4 条评论
  • Business Central and OneDrive

    Business Central and OneDrive

    Lately I was searching in the BC19 preview container and when I want to change the company I have noticed a new option…

    7 条评论

社区洞察

其他会员也浏览了