Installing and Configuring Components for Communication using Azure Service Bus Relay
The setup of the components needed to print receipts on a fiscal printer should be carried out in three places:
- Azure Portal - configuration of Azure Service Bus Relay,
- Business Central,
- a Windows machine (an internet-enabled machine or a VM on Azure) – this machine will be used to run BCAgentService, which is used to access local resources.
When setting up the services on Azure Portal, define parameters to be used in further steps of connection configuration. In this article, the steps related to defining and using parameters will always be marked with Underline.
Component Configuration in Azure Portal
To configure components in Azure Portal:
- Create a resource. For details, read Create a Relay namespace using the Azure portal.
The resource name must be unique throughout the whole Azure Portal. For example, the name can include the name of the customer.
Important
A single resource can contain a configuration for multiple printers, so you don't need to create more than one resource for a given Relay resource.
The parameter namespace name has the same value as the Relay resource name.
The parameter namespace address has the same value as the Relay resource, along with the suffix ".servicebus.windows.net", i.e. "namespace name.servicebus.windows.net".
Tip
For details, read Relay Hybrid Connections WebSockets in .NET* on Microsoft Learn.
Tip
Repeat the following steps for each new printer. 2. On the Relay page, choose Entities on the navigation bar, then select Hybrid Connections. Create a new hybrid connection.
Important
The configuration of each printer requires an individual hybrid connection, so the name may indicate, for example, the location of a given printer.
hybrid connection name is the value of the hybrid connection name paraemeter.
On the new hybrid connection page, choose Settings, then select Shared access policies. Create two new Policy elements
- with the Sender name and select the Send field (the parameter value name Sender policy is Sender),
- with name Listener and a marked field Listen (parameter value name Listener policy to Listener).
In the Policy view, copy the Primary Key value for each element.
- Copied Primary Key with Sender is the value of the Sender policy key. parameter
- Copied Primary Key with Listener is the value of the Listener policy key parameter..
Configuration in Dynamics 365 Business Central
The following procedure explains how you can configure Azure Service Bus Relay in Dynamics 365 Business Central
To configure the fiscal printer, read Fiscal Printer Configuration and perform the following steps:
Choose the
icon, enter Fiscal Printers, and then choose the related link.
On the Fiscal Printer Card page choose the Azure Relay Setup.
On the Azure Service Bus Relay Setup page, fill in the required fields as follows:
Azure Relay namespace - namespace name.
Hybrid Connection Name - Hybrid Connection.
Shared Access Policy Name - the ender policy name.
Shared Key - Sender policy key.
Configuring BCAgentService on a Windows Machine
The following procedure explains how you can configure BCAgentService on a Windows machine.
Important
Before proceeding with the configuration, download the appropriate BCAgentService file from the Additional Components directory available at IT.integro Product Portal.
Important
You must select the appropriate location for the service. The machine name must not contain any whitespaces. BCAgentService will reference and retrieve libraries from this location, so you will not be able to change the location once the service has been created.
- Unzip the BCAgentService.zip file to the location you select on your Windows machine.
- Run PowerShell as an administrator.
- To verify that the libraries are not locked, run the following command:
Get-ChildItem -Path <plugin folder path> -Recurse | Unblock-File
where:
- <plugin folder path> - Specifies the path to the library folder.
example:
Get-ChildItem -Path C:\BCAgent_Service\Plugins -Recurse | Unblock-File
- To allow executing unsigned scripts, run the following command:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
- To create services, download the Installation script file, and then run the following command:
Install-BCAgentService.ps1 <exe path> -namespace <namespace url> -connectionName <hybrid connection> -keyName <policy name> -key <policy key> -pluginfolder <plugin folder path>
where:
- <exe path> - file path BCAgentService.exe located in the selected path for the agent,
- <namespace url> - namespace address
- <hybrid connection name=> - hybrid connection name
- <policy name> - Listener policy name
- <policy key> - Listener policy key
- <plugin folder path> - The path to the library folder that is located in the agent folder.
A sample command can be in the form:
Install-BCAgentService.ps1 C:\BCAgent_Service\BCAgentService.exe -namespace customername.servicebus.windows.net -connectionName shoplocation -keyName Listener -key 1a2b3c4d5e -pluginfolder C:\BCAgent_Service\Plugins
Setup Testing
The following procedure explains how to test the connection between Dynamics 365 Business Central and the fiscal printer using the configured agent.
In the Dynamics 365 Business Central icon select the
icon, enter Fiscal Printers, and then choose the related link.
On the Fiscal Printer Card page, choose the Test Connection.
Note
Errors that may occur when testing the connection mean that: - The printer is not connected correctly to Azure Service Bus Relay. - the fiscal printer is configured differently compared to the settings in Dynamics 365 Business Central; - Azure Relay configuration on the Dynamics 365 Business Central is incorrect.
- When the connection test is successful, you can print a test receipt. To do so, choose the Print Test Receipt on the Fiscal Printer Card page.
Note
Printing a test receipt is recommended only if the fiscal printer is working in training mode.