Site icon Patrick Schiefer

The (rather) unknown superstar “BCAgent”

Some weeks ago a collegue of mine akt me if there is a simple way of accessing client ressources from Business Central SaaS (and of course also OnPrem), without using .net directly from AL.

I remembered a session where someone talked about the BCAgent (I guess it was on BC TechDays). After some researching I found the concept of the BCAgent on https://aka.ms/BCTech

The main concept of it is to forward calls via an Azure Relay to a local client service. From this windows service you can access ever client ressource you want, without exposing a port to the public

In our case we used this to access a smart card terminal and local printers.

Challenges

The BC Agent is pretty good documented in the BC Tech Samples repository. But the documentation of the Relay was not so good therefore, here is how you do it. The first problem was that Microsoft is using different names for the ressource, in Azure Portal it’s called “Relay”, but they also talking about “Azure Service Bus” and “Azure Service Bus Relay”. Keep in mind that this three names are pointing to the same ressource type

  1. Go to https://portal.azure.com
  2. In the ressource search, search for “Relays”
  1. Like every Azure ressource choose “Subscription”, “Ressource Group”, “Name” and “Location”
  2. Now we have an Relay ressource, we could now create a so called “Hybrid Connection”

Give it a name and make client authorization required

  1. Open the hybrid connection and create

I would suggest to create two access policies, one for send and one for listen

  1. When you open the policy you get the key for it
  2. Now you can start the BCAgent Service like described here
    Using following values
    dotnet BCAgent.dll
    -namespace:{name of the relay}.servicebus.windows.net
    -connectionname:{hybrid connection name}
    -keyname:{Name of the policy}
    -key:{Key from policy}
  3. When you go back to the hybrid connections now you should see one connected listener

When everything is setup correct, you now can execute code on your local machine.

Pricing

Accorid to this Microsoft site, the relay costs 9.213 € per month per listener. But there are also some costs for Data Transfer. To keep the costs for Data Transfer as small as possible we also use an Azure Storage Account to send large payloads (for example print files)

Usage Examples

Conclusion

With this approach, Microsoft makes it very easy to handle a load of problems which cloud computing brings. We can solve many problems which we have solved directly in C/SIDE back in the days

Exit mobile version