Views:

Applies to Product - Dynamics 365 Business Central


What’s happening?
How to attach documents to items, orders, etc. that are stored in Azure File Share within Microsoft Dynamics 365 Business Central.


Reason:
Migrated from an on-premises system to Business Central SaaS and requiring a method to link external documents stored in Azure File Share, as previous methods using UNC paths are no longer valid.


Resolution:
To attach documents to items and orders stored in Azure File Share, follow these steps:

  1. Set Up Azure Storage: Ensure that you have an Azure storage account and the necessary containers set up to store your documents. You will need the access key for authentication.
  2. Create a Setup Table: In Business Central, create a setup table to enter the Azure storage account details, including the source and destination containers along with the access key.
  3. Develop a Page Extension: Create a page extension for the Document Attachment feature. This will allow you to download the blob files from Azure and attach them to your documents in Business Central.
  4. Implement Code to Access Blob Files: Use the Azure Blob Storage client to read the files. Initialize the client with the shared access key and retrieve the list of blobs from the specified container.
  5. Attach Documents to Purchase Invoices: Create a function that retrieves the blob file as a stream and attaches it to the purchase invoice. This involves creating a purchase header and using the PutBlobBlockBlobStream function to copy the stream file to the destination.
  6. Publish Your Code: After implementing the necessary code, publish it to your Business Central environment.
  7. Run the Job Action: Finally, run the job action button on your setup page to execute the process of attaching the documents to the items or orders.
Additionally, consider using third-party apps like Dynavision Drag and Drop or Documents Storage from AppSource, which provide enhanced functionalities for managing attachments with Azure Blob Storage.