In 2021 there will be a monthly blog every month covering the webinar of the month for Low-Code Application Development (LCAD) for Azure solutions. LCAD on Azure is a solution that demonstrates the robust development capabilities of integrating Microsoft Power Apps with low code and the Azure products you may be familiar with.
This month’s webinar is “Unlock the future of Azure IoT through Power Platform. “In this blog I will briefly summarize LCAD on Azure, provide an overview of IoT in Azure and Azure functions, how to drag an Azure function into Microsoft Power Automate and how to integrate your Power Automate flow into Power Apps.
What is LCAD on Azure?
LCAD on Azure is designed to help developers build business applications faster with less code. By using Microsoft Power Platform and especially Power Apps, developers can scale and extend their Power Apps with Azure services. For example, a Pro developer working for a manufacturing company would need to create a line-of-business (LOB) application to help warehouse workers track incoming inventory. It would take months to build, test, and deploy this application. With Power Apps, creation can only take hours – that saves time and resources.
For example, suppose the warehouse workers want the application to automatically place supply orders for additional inventory when the current inventory hits a certain low point. In the past, the development team needed another heavy lift to revise the previous application iteration. With the integration of Power Apps and Azure, a professional developer can create an API in Visual Studio (VS) code, publish it in their Azure portal, and export the API to Power Apps and integrate it into their application as a custom connector.
After that, the same API in the Power Apps studio can be reused indefinitely for future use with other applications, saving the company and developers more time and resources.
IoT for Azure and Azure functions
In this webinar you will learn how to control an IoT device with Azure IoT Hub and Power Apps. To start with, you would write the code in Azure IoT Hub to send commands directly to your IoT device. In that webinar, Samuel wrote in Node for Azure IoT Hub and wrote two basic commands: to turn the fan on and off.
The commands are sent through the code in Azure IoT Hub, which is initially executed locally. After testing and confirming that it is working properly, the next question is, how can the API be called quickly from anywhere in the world? The answer is to create a flow in Power Automate and connect that flow to Power Apps. This is a complete dashboard that controls the IoT device from anywhere in the world. To do this task, you first need to create an Azure Function, which is then obtained using a in Power Automate Receive Function that creates the flow.
After you’ve created the Azure Function, first run it locally and test it. Test the power on and off status using the Azure Function URL. To create a trigger for the Azure Function, in this case a Power Automate Flow, you need to create an Azure Resource Group to validate the Azure Function and test its on-premises functions. If the test fails, it may be that you have not or have not created an access token for the IoT device. To connect a device, IoT or other means to the cloud, you need an access token.
In the webinar, Samuel added two application settings for the on and off commands to his role. After adding these access tokens and adjusting the settings of the IoT device, Samuel was able to successfully run his Azure function.
Azure function automated with Power Automate
After creating the Azure function, you can create your Power Automate flow to start creating your globally accessible dashboard for the operation of your IoT device. Samuel first creates a basic Power Automate framework, then runs a flow and shows how to test the flow once it is complete. It starts with an HTTP request and implements a Receive Command. From there, it’s a straightforward process to test the IoT device and get it working.
Power Automate flow in Power Apps
After you’ve created your Power Automate flow, develop a simple user interface for turning the fan on and off. To do this, create a Canvas Power App and import the Power Automate flow into the app.
First, create a blank canvas app and name it. In the Power Apps ribbon, select buttonand select the source of the button and choose Power Automate and Add a flow. Select the flow that is connected to the Azure IoT device. The name should appear in the selection menu. If everything goes right, your IoT device will turn on. In the webinar, Samuel is running out of time and he’s creating a new Power Automate flow that he imports into the Canvas app.