One way to make available data from Business Central to different parties and users is to leverage Azure Storage.
Customers will need to have an Azure Portal subscription.
There are 4 types of storage in Azure portal: Blob Containers, File Shares, Queues, and Tables.
Today’s blog is about Azure Storage Tables and its API.
More on its API here.
In this blog I covered:
- create a storage account table using Azure Platform;
- insert data in the storage account table via VS Code extension “Rest Client”;
- an extension to send Business Central vendor data to the Azure Storage table;
- using Excel to share Azure Storage table data with 3rd party users.
Create storage account and storage account table
I created through the Azure portal one storage account and a few tables stored inside that storage account.
You can insert manually data in these tables using Azure Storage Explorer.
Let’s see how we can interact with them first via Rest Client (extension for VS Code), and then via Business Central extensions.
Using Rest Client to interact with Azure Storage Table
1. we can query the Azure Tables via Rest Client in VS Code:
[in the picture insert your SAS token right after “?”]
2. Query Vendor table:
3. Insert new record in Vendor Table:
Let’s now verify in Azure portal the last action:
Use Azure Storage Table API from Business Central
With the API tested, let’s now move to Business Central and AL and try to insert records in the Azure tables.
The sample code I worked on will scan all vendors and send Vendor.”No.” and Vendor.Name to the Vendor table in Azure Storage.
When creating a new table in Azure Storage Table, each table comes by default with the 2 fields:
In my example, PartitionKey will be empty, but you could populate it with the company name.
RowKey will be populated with Vendor.SystemId.
“Azure Storage Setup” it’s an extension table to keep all that great Azure stuff:
To log the work done by the Post request I created table and a page and I am inserting records in this table with each successful Post request.
Use the Azure Storage Explorer to view records in the Azure Portal:
What about the 3rd party users?
How do we give them access to the data in the storage table?
The good old Excel is here to contribute.
Use of Excel to share Azure Storage Data with 3rd party users
- go to Data menu
- Get Data -> From Azure Storage Table
- when prompted enter for the “Account Name or URL” enter the storage URL:
- For access key enter the access key from storage account
And this is what we get:
Click on Load, and then double click on Vendor Connection:
PowerQuery is opening and we can enable the other fields (by clicking on Content column and select the missing columns):
You can find the AL sample code here.