Skip to content

Commit

Permalink
New System App Module for easy file systems access (#663)
Browse files Browse the repository at this point in the history
Migration of microsoft/ALAppExtensions#23225

Now that we have made several clients Universal code ready.
One of the main problems turned out to be the replacement of the file
record and the file object (File.Create, File.Exists).
Some of our customers now use Azure Blob Service from the System app.
Others don't have a good internet and now use a local microservice with
REST API, others use Azure File Shares.
The problem is that every integration is different. I think many other
partners will have the same problem.
To simplify access I have adopted the email module and created new file
accounts.
With just one codeunit, a developer can now connect to various file
services without having to know how they actually work. The code unit
"File System" delviers everything taht is needed.

An additional PR contains three connector apps:
microsoft/ALAppExtensions#23225

This Apps will conenct:
 - Azure Blob Storage
 - Azure File Share
 - SharePoint Online

All three service can be access over **one** unified interface!

New provider in the future could be:
 - a OneDrive Provider
 - Third Party file services

An example that shows how simple it is to use the new modules can be
found here:
https://github.com/IceOnly/BC_FileSystem_Example

But before I go round the whole thing, I'm interested in whether there
is any interest in the module at all.

Here are some Screenshots:

![image](https://user-images.githubusercontent.com/3911556/236433843-11ee0b26-ee9c-4da2-8bc6-efb32675090c.png)

![image](https://user-images.githubusercontent.com/3911556/236433887-bf2bf2f2-f68e-4efa-9db5-074a6f68fad0.png)

![image](https://user-images.githubusercontent.com/3911556/236433950-e8117496-16f6-4b25-a575-42ba729ca6c3.png)

![image](https://user-images.githubusercontent.com/3911556/236434182-97fd304a-95ac-4180-9d52-9ead78899822.png)

![image](https://user-images.githubusercontent.com/3911556/236435173-a01a77bc-04de-4063-b0bb-bf18e28b2817.png)

![image](https://user-images.githubusercontent.com/3911556/236435258-56d68d50-7581-4527-bcdd-5b6e3ed53ac8.png)

I have decided in favour of some restrictions. Paths must not start with
a /. The only supported path separator is /. If services that require a
\ are to be connected, this must be translated by the connector app.

These restrictions should ensure that the file service can be exchanged
without upgrading data.

Assigned Workitems:
Fixes #2418 
Fixes
[AB#559148](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/559148)

---------

Co-authored-by: Stefan Sosic <[email protected]>
Co-authored-by: Jesper Schulz-Wedde <[email protected]>
Co-authored-by: Darrick <[email protected]>
  • Loading branch information
4 people authored Dec 20, 2024
1 parent de1a1ff commit 0e9b78e
Show file tree
Hide file tree
Showing 53 changed files with 4,916 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace System.Security.AccessControl;
using System.Azure.Identity;
using System.Environment.Configuration;
using System.Email;
using System.ExternalFileStorage;
using System.Apps;
using System.Integration;

Expand All @@ -25,6 +26,7 @@ entitlement "Delegated Admin agent - Partner"
"Exten. Mgt. - Admin",
"Email - Admin",
"Feature Key - Admin",
"File Storage - Admin",
"VSC Intgr. - Admin";
#pragma warning restore
}
7 changes: 7 additions & 0 deletions src/System Application/App/External File Storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# External File Storage Module for Business Central
Provides an API that lets you connect external cloud storage accounts to Business Central, allowing users to access files stored outside of Business Central.

## Main Components

### File Account
A file account holds the information needed to access an external storage service from Business Central.
70 changes: 70 additions & 0 deletions src/System Application/App/External File Storage/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"id": "c9c54414-80c3-4cc9-98c6-589158882774",
"name": "External File Storage",
"publisher": "Microsoft",
"brief": "Access external file storage services",
"description": "Enables access to external file storage services from Business Central.",
"version": "26.0.0.0",
"privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009",
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120",
"help": "https://go.microsoft.com/fwlink/?linkid=2103698",
"url": "https://go.microsoft.com/fwlink/?linkid=724011",
"logo": "",
"dependencies": [
{
"id": "7e3b999e-1182-45d2-8b82-d5127ddba9b2",
"name": "DotNet Aliases",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "872fe7e8-9893-40ae-ab94-c123ed30fdbd",
"name": "Extension Management",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "de35f591-7216-4e60-8be1-1911d71a7fc2",
"name": "Telemetry",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "0846d207-5dec-4c1b-afd8-6a25e1e14b9d",
"name": "Base64 Convert",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "a4584a53-9345-458a-af20-d1df2fab7bd8",
"name": "Confirm Management",
"publisher": "Microsoft",
"version": "26.0.0.0"
},
{
"id": "e31ad830-3d46-472e-afeb-1d3d35247943",
"name": "BLOB Storage",
"publisher": "Microsoft",
"version": "26.0.0.0"
}
],
"internalsVisibleTo": [
{
"id": "f188754b-3ffb-443a-9507-f5fbdae3af2c",
"name": "External File Storage Test Library",
"publisher": "Microsoft"
}
],
"screenshots": [

],
"platform": "26.0.0.0",
"idRanges": [
{
"from": 9450,
"to": 9459
}
],
"target": "OnPrem",
"contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2134520"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.ExternalFileStorage;

permissionset 9450 "File Storage - Admin"
{
Access = Public;
Assignable = true;
Caption = 'External File Storage - Admin';

IncludedPermissionSets = "File Storage - Edit";

Permissions =
tabledata "Ext. File Storage Connector" = RIMD,
tabledata "File Storage Connector Logo" = RIMD,
tabledata "File Account Scenario" = RIMD,
tabledata "File Scenario" = RIMD,
tabledata "File Account Content" = RIMD;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.ExternalFileStorage;

using System.Environment;

permissionset 9453 "File Storage - Edit"
{
Access = Public;
Assignable = false;
Caption = 'File Storage - Edit';

IncludedPermissionSets = "File Storage - Read";

Permissions = tabledata "File Storage Connector Logo" = imd,
tabledata "Tenant Media" = imd;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace System.ExternalFileStorage;

permissionset 9452 "File Storage - Objects"
{
Access = Internal;
Assignable = false;

Permissions =
codeunit "File Account" = X,
codeunit "External File Storage" = X,
codeunit "File Pagination Data" = X,
codeunit "File Scenario" = X,
table "File Account" = X,
table "File Account Content" = X,
table "File Account Scenario" = X,
table "File Scenario" = X;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.ExternalFileStorage;

using System.Environment;

permissionset 9451 "File Storage - Read"
{
Access = Internal;
Assignable = false;
IncludedPermissionSets = "File Storage - Objects";

Permissions =
tabledata "Ext. File Storage Connector" = r,
tabledata "File Storage Connector Logo" = r,
tabledata "File Account Scenario" = r,
tabledata "File Scenario" = r,
tabledata "File Account Content" = r,
tabledata Media = r; // This permission is required by External File Storage Account Wizard
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.ExternalFileStorage;

/// <summary>
/// Provides functionality to work with file accounts.
/// </summary>

codeunit 9450 "File Account"
{
Access = Public;

/// <summary>
/// Gets all of the file accounts registered in Business Central.
/// </summary>
/// <param name="LoadLogos">Flag, used to determine whether to load the logos for the accounts.</param>
/// <param name="TempFileAccount">Out parameter holding the file accounts.</param>
procedure GetAllAccounts(LoadLogos: Boolean; var TempFileAccount: Record "File Account" temporary)
begin
FileAccountImpl.GetAllAccounts(LoadLogos, TempFileAccount);
end;

/// <summary>
/// Gets all of the file accounts registered in Business Central.
/// </summary>
/// <param name="TempFileAccount">Out parameter holding the file accounts.</param>
procedure GetAllAccounts(var TempFileAccount: Record "File Account" temporary)
begin
FileAccountImpl.GetAllAccounts(false, TempFileAccount);
end;

/// <summary>
/// Checks if there is at least one file account registered in Business Central.
/// </summary>
/// <returns>True if there is any account registered in the system, otherwise - false.</returns>
procedure IsAnyAccountRegistered(): Boolean
begin
exit(FileAccountImpl.IsAnyAccountRegistered());
end;

var
FileAccountImpl: Codeunit "File Account Impl.";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.ExternalFileStorage;

/// <summary>
/// A common representation of a file account.
/// </summary>
table 9450 "File Account"
{
Extensible = false;
TableType = Temporary;

fields
{
field(1; "Account Id"; Guid) { }
field(2; Name; Text[250]) { }
field(4; Connector; Enum "Ext. File Storage Connector") { }
field(5; Logo; Media)
{
Access = Internal;
}
}

keys
{
key(PK; "Account Id", Connector)
{
Clustered = true;
}
key(Name; Name)
{
Description = 'Used for sorting';
}
}

fieldgroups
{
fieldgroup(Brick; Logo, Name) { }
}
}
Loading

0 comments on commit 0e9b78e

Please sign in to comment.