Azure File, Azure Blob and Alibaba Cloud integration in Business Central (with interfaces and telemetry)

A codeunit to upload files to different containers, implemented with interfaces and monitored with telemetry

SCENARIO

  • The requirement is to replace the reference of “File Management” codeunit with a new “Azure File Management” for the SaaS (Cloud) version of Business Central.
  • I want to implement a base “app” that manages file basic operation on different cloud platforms: upload, download, create folders, copy and move files and folders.
  • I want the app to be reusable by all other app depending on it.
  • I want to monitor the activity with telemetry and application insights.

THE WONDERFUL WORLD OF INTERFACES AND TELEMETRY

This project allows me to use in the real world two of the new powerful and wonderful features of Business Central: interfaces and telemetry. Interfaces are available with a minimum of runtime 5 (you have to kiss goodbye older versions of BC).

AZURE BLOBS VS AZURE FILES

One of the requirement was to work with Azure Files, not just with Azure Blobs. The web is full of samples of Azure Blobs integration but it lacks Azure Files implementation.

As you should already know, Azure Files and Azure Blobs are two different containers and you deal with them with a different set of APIs.

THE PROJECT

First of all I implemented the interface, in my GitHub sample I only give you the code of Download() 🙂

Then I implemented Download codeunits for Azure Files and Azure Blobs.

The “ALV AzBlob Service API” contains Azure Blob implementation, to deal with blobs is really easy and with a few lines of code the job is done. This is a dummy copy/paste from Demiliani sample integrated with telemetry monitoring.

The Azure File, implemented in “ALV AzFile Service API”, drove me mad because I didn’t find any ready-to-use solution on the internet and I had to implement all by myself.

The Azure Files management involves a tricky feature to calculate a Base64Hash SharedKey by using “Cryptographic Management” codeunit. The azure file API needs an authentication procedure which is not so easy to implement from scratch in AL language. By the way, here it is.

The “ALV Application Insights Mgt.” and “ALV Application Insights SDK” allow to deal with azure application insight telemetry. The Management codeunit implements the TraceInformation(), TraceError() and all the other function to write logs data.

I added just a function to manage telemetry where I manage the telemetry duration.

GITHUB SOURCES

https://github.com/avalonit/ExBcPepperiConnector

APPLICATION INSIGHT AND TELEMETRY FOR BUSINESS CENTRAL

https://github.com/mynavblog/ApplicationInsights

http://www.mynavblog.com/category/navdevtips/

AZURE FILE API REFERERENCE

https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-requests-to-azure-storage

https://docs.microsoft.com/it-it/rest/api/storageservices/file-service-rest-api

COMING SOON

In next article I will cover how to access telemetry and how to implement Alibaba Cloud Container Download() function.

LAST UPDATED

30th of May, 2020

One thought on “Azure File, Azure Blob and Alibaba Cloud integration in Business Central (with interfaces and telemetry)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s