Watch the video where a user, with no coding skills, can call (score) a SAS decision, from an app on his mobile phone. Read the article to understand the integration between Microsoft Power Apps and a SAS decision published to Azure with SAS Container Runtime. The decision is deployed to an Azure Web App and called through a REST API.
The first two steps were explained in detail in How to Publish a Decision to Azure with SAS Container Runtime.
In your Azure portal, create a Web App. Select Publish > Docker Container:
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
Only if you have an App Service plan, select it. Azure App Service plans might be discussed in a future article.
In the Docker tab:
Further, go to Review and Create.
After deployment, the web application URL will be https://AppName.azurewebsites.net/ while the SCR REST API will listen on https://AppName.azurewebsites.net/SCRimagename:8080 .
Specific to SCR container images, you need to tell Azure on which port the SCR REST API will be listening.
From Settings > Configuration, create a new application setting called WEBSITES_PORT with the value 8080.
From now on, all traffic sent to https://AppName.azurewebsites.net/SCRimagename will be sent through port 8080.
Note: To complete the following steps, you will require a Premium Power Apps license.
The SCR REST API returns a JSON string. However, Power Apps cannot convert directly the JSON string into data.
One of the possible solutions is to use a flow. The flow collects inputs, passes them to the Azure Web App (SCR runs inside), then it parses the JSON for Microsoft Power Apps:
Go to Power Apps > Flows and create a new flow.
Here, the app runs the flow, which calls an Azure Web App, with a SCR decision inside.
Inputs from the application are expected as strings. You require one Initialize variable step per input.
The HTTP step is calling the SCR REST API, listening inside the Azure Web App at https://APPName.azurewebsites.net/SCRimagename .
The request body is parametrized with the input variables collected.
String inputs from Power Apps must be converted to numeric if the decision expects numeric inputs. Therefore, it is your job to know what data types the decision inputs and outputs are. You have to match or convert them to the expected application input data types.
On a side note, the flow HTTP step and the curl command below will produce the same results:
You can read more about scoring commands in How to Score a SAS Decision Published to Azure with SCR.
The last three steps will convert the response, from a JSON string, into an array, that can be parsed inside Power Apps.
The application created is deliberately minimalistic. There is one screen for the inputs, the action button and the decision output.
Inputs are collected through text labels, just like in a web form.
The Power Automate flow becomes the data source.
The button’s OnSelect property is perhaps the most important in this app:
AutoAuctionFlow.Run(state.Text,Make.Text,Model.Text,CurrentBid.Text,BlueBookPrice.Text,Miles.Text)
ClearCollect(
bidInfo,
AutoAuctionFlow.Run(state.Text,Make.Text,Model.Text,CurrentBid.Text,BlueBookPrice.Text,Miles.Text) );
From the collection bidInfo, the bidCommand value is selected and displayed. The label represents the SAS decision output.
When you tested the application sufficiently, you can publish or share the application with other users in your organization.
Download PowerApps from Apple Store and you can use the application you created instantly.
You can score SAS decisions, or models, from a Microsoft Power Apps application. This approach increases dramatically the audience and the consumption of SAS decisions and models. Microsoft Power Apps provides a low-code development environment. The Microsoft Power Apps application calls the SAS decision published to and running in Azure, through the SAS Container Runtime REST API.
Thank you for your time reading this article. If you liked the article, give it a thumbs up. Please comment and tell us what you think about the new SCR and Azure publishing destination.
Find more articles from SAS Global Enablement and Learning here.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.