This article details a starter app, as described in the viyaapp GitHub repository, to setup your SAS Viya Web Application with minimal effort. Note: viyaapp is a branch of the restaf-uidemos repository. Upgrading from the sample application to your own application is as simple as replacing the index.html file and setting some configuration values. Additionally, creating a docker container for your application is a snap, as you'll see documented in this posting.
You need to do this for all applications that will access SAS Viya. Typically these are set up by a SAS Viya Administrator.
The starter application uses @sassoftware/viya-appserverjs as its app server. The primary purpose of the app server is to handle authentication and serve up the application to the browser.
As you will notice, the application has quite a few configurations. All these configurations are read by the application server to setup the application. Visit this wiki pages for details.
Clone the repository and install the dependencies
git clone https://github.com/sassoftware/restaf-uidemos -b viyaapp viyaapp npm install cd viyaapp
Edit the .env file in the cloned repository and set the value of VIYA_SERVER to your SAS Viya server url.
VIYA_SERVER=https://Your-viya-server-url CLIENTID=clientapp CLIENTSECRET=secret APPNAME=viyaapp APPHOST=localhost APPPORT=5002 # If APPENTRY is not specified, it defaults to index.html APPENTRY=index.html
Go to your browser and enter this to access the application
You should get the SAS Logon dialog. Logon on with you SAS Viya userid and password. This will open the application.
The application is simple on functionality. It lists the available files on the SAS server. Press the button to display the file list.
The default application is in public/index.html. The full html is shown below with embedded notes.
"authType": "server", "redirect": null, /* advanced feature */ "host" : "your viya server url", "clientID": "your client id", "appName" : "The value of the APPNAME field in the .env file", "keepAlive": null, /* advanced feature to keep the session alive for longer periods */ "ns" : null /* for future use
Change the value of APPENTRY in the .env file to the value below. Restart the application and visit the same site for a more interesting starter app.
To run your application in docker, edit the docker-compose file. Set the value of VIYA_SERVER to the appropriate value.
version: "3.8" services: viyaapp: build: . restart: always ports: - 5002:8080 environment: - VIYA_SERVER=https://<your viya url> - CLIENTID=clientapp - CLIENTSECRET=secret - APPNAME=viyaapp
Note: The docker-compose command uses the Dockerfile in the same directory to create the container. The application is running on port 8080 in the container and the port is mapped to 5002 in the docker-compose file.
To run the application in docker run the following command.
docker compose up
and access the application as before.
You just built a simple web application for SAS Viya with minimal effort. To make it your own, replace the contents of the public directory with your assets and modify the values in the configuration files.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.