BookmarkSubscribeRSS Feed

Use a Power App app with Power Platform connector having an SAS Viya REST API endpoint (part 1)

Started ‎05-16-2023 by
Modified ‎05-15-2023 by
Views 1,496

Introduction

 

On developer.sas.com it says that the SAS Viya REST APIs are designed for enterprise application developers, who intend to build on the work of model builders and data scientists, to deliver apps based on SAS Viya technology. With the SAS Viya REST APIs, you can create and access SAS resources using any third party application that supports http(s) calls.

 

Microsoft Power Platform connectors are wrappers or proxies around an API that allow the underlying service to talk to Microsoft Power Automate, Microsoft Power Apps, and Azure Logic Apps. SAS offers a SAS Decisioning Connector to run SAS Intelligent decisions that are deployed on your SAS Viya platform.

 

However Microsoft also gives you the option to build your own custom connectors which allows you to communicate with services that aren't available as prebuilt connectors. That way you could for instance connect from within PowerApps to a SAS model published in a SAS Scoring Container.

 

In this blog series that is split up in to three different parts, we will explain how you can create a Power App application that displays data retrieved from your SAS Viya environment. In the first part of the blog we will start with creating custom connector that list data loaded into the SAS Cloud Analytic Services (CAS)

 

Prerequisites

The SAS Viya environment use TLS to secure data in motion.  You need a certificate from a commercial vendor like Digicert or Verisign.  Self signed certificates are not be trusted by the Power Automate of Power App platforms of Microsoft. And you are not able to import a self signed certificate.

 

In case the SAS Viya environment is protected by a firewall, you will need to whitelist the IP from which Power Automate requests are sent. More info about these IP addresses can be found here.

 

Create a Power Platform custom connector

 

image1.png

 

Go to make.powerautomate.com and sign in to your Microsoft account. Click on New custom connector and select Create from blank.

 

custom connector.png

 

Give the connector a name.

 

custom connector name.png

 

Now you can use a wizard that will guide you through the steps necessary to create your customer connector in Microsoft Power Automate. We will guide you through each of these steps and call out what needs to be setup for your custom connector.

 

menu.png

 

General

 

Fill in your Viya hostname in the Base URL field.

 

viya-server.png

 

Security

 

Now click on Security. Choose API key as authentication and fill the fields like you see below.

 

security.png

 

Definition

 

Click Definition and in the next screen you can determine actions that users will be able to perform. In our example we will only add 1 action: the retrieval of a number of rows from a CAS table. We start by clicking on New action and then we will define some general properties of the actions.

 

definition-1.png

 

After that it's time to specify the details of the Request, for that you can click Import from sample.

 

import frm sample.png

 

Enter the following URL. We are going to modify the values between the brackets.

 

https://{viya-fqdn}/casRowSets/servers/cas-shared-default/caslibs/{cas-lib}/tables/{cas-table}/rows?limit=a&start=b

 

Parameter Description
viya-fqdn The fully qualified domain name of the SAS Viya server.
cas-lib The CAS library where the table is located.
cas-table The CAS table name.

 

*) Leave the limit and start parameter to the respective values as shown above

 

Click Import.

 

request.png

 

Test

 

Before you are able to test the newly created customer connector you need to first save it by clicking on Create connector.

 

test create.png

 

Once the custom connector has been saved we can start our test. But first we have to create a new connection. If no connection is listed click on "New connection"

 

image10.png

 

To establish the connection to the SAS Viya environment you need to provide an API key. This API key is something that needs to be generated within the SAS Viya environment. How to generate this API key can be found here.

 

 

image11.png

  

The API key needs to be in this format: Bearer <access_token>.  An example of what the API key could look like is shown here.

 

Bearer eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vbG9jYWxob3N0L1NBU0xvZ29uL3Rva2VuX2tleXMiLCJraWQiOiJsZWdhY3k

tdG9rZW4ta2V5IiwidHlwIjoiSldUIn0.***********************6InVpZD12aX***********l9zaWciOiI4YTdjYzE4Ni0xZjE1L

T***************************31HN-Upuhs-PKk7SEn_FWRyL0tasi0nNb_H0f****************VARJo67cpzyBxyv1gQg

 

You can validate if the connection was created successful by selecting connections:

 

image12.pngimage13.png

You can go back to customer Custom connectors to test the connection. Click Test operation.

 

If the Access Token was generated correctly you will be able to run a successful test.

 

image14.pngimage15.png

 

That concludes the creation for the custom connector. Now you're all set to create a Power Automate Flow which can be used in a later step in a Power App. We will explain how to do that in the second part of our blog series.

 

Let us know if you have any questions in the comments!

Version history
Last update:
‎05-15-2023 03:24 AM
Updated by:
Contributors

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags