This is part of the series Badge printing and more with Power Apps
After choosing the printer the challenge was to send the print job to it. As explained in the previous post, the printer would be available only on local network, so there is no direct access from Internet to it. That’s why we had to establish a link between Power Apps (Microsoft 365) and the local IP address of our printer (on-premises network) and send the print job.
But how?
Let’s describe the process from the end to start:
- The badge would be printed by the printer
- the Brother printer understands ESC/P commands
- containing the ESC/P commands, a file should be generated including the visitor information
- the visitor information should be transferred to a local server by a Flow (Power Automate)
- the Flow collects the visitor information from Power Apps App
- the visitor information should be transferred to a local server by a Flow (Power Automate)
- containing the ESC/P commands, a file should be generated including the visitor information
- the Brother printer understands ESC/P commands
Ok, now let’s start from the beginning like normal people 🙂
The Flow collects the visitor information from Power Apps App
This step is straightforward, one needs to create a Flow which will be called by the Power Apps app using parameters.
There is a template for that called “Power Apps button”. I recommend you this video about how to handle the parameters generated by “Ask in PowerApps”.
We are passing the following information from Power Apps: first name, last name and company name.
The visitor information should be transferred to a local server by a Flow (Power Automate)
In the Flow created in the previous step we need to add a new action and generate a .txt file and save it on a local server. Here comes the on-premises data gateway in action:
On-premises data gateway
Microsoft has that figured out and provides local access through the On-premises data gateway. The service was originally built for PowerBI (hence the service name PBIEgwService) but it can be used by the Power Platform products: Power Automate, Power Apps.
Be aware that the on-premises gateway is a premium feature and requires a premium license!
Installation and configuration
- Installing the gateway
- Signing in and configuring proxy (if needed) and service user
- Test connectivity
- Test if service is running
After that this new gateway should appear in the list in Power Automate Portal -> Data -> Gateways
Adding a new connection in Power Automate using the newly created Gateway
In order to generate and save a file on a local server we must create a new connection using the gateway.
This is done in Power Automate Portal -> Data -> Connections -> New Connection -> File System
Root folder is required and must a folder path (e.g. \MACHINE\myShare or C:\FolderName)
Authentication Type is “Windows”
Username is required and is the local username credential (e.g. DOMAIN\Username)
Password is required and is the local password credential
Gateway is required and is a selection of created gateways
Here is the official Microsoft documention about the File System Connector
Now we are able to add “Create File” operation using the Connection created above and specifying then path and the file contents.
In the next blog post from this series we will handle the ESC/P commands and converting the collected visitor information to a format that can be understood by the printer.