BookmarkSubscribeRSS Feed

How to Score a SAS Model in an Azure Container Instance

Started ‎10-17-2021 by
Modified ‎10-31-2021 by
Views 4,461

SAS Container Runtime (SCR) allows you to publish a SAS model as a container image in Azure. In this post you will learn how to create a container instance in Azure. Then, how to score the model using a simple curl command.


SAS Container Runtime (SCR)

SAS Container Runtime  (SCR, pronounced "soccer") is available since the SAS Viya version 2021.1.3. Azure, as a SAS model publishing destination is available from the same version.


SAS Container Runtime:

  • Does not require SAS Viya for execution.
  • Has a much smaller runtime compute cost.
  • Uses standard technology such as Docker and container registry.
  • Has a smaller footprint for production.
  • Is highly scalable.
  • Gives you more choices. SAS container runtime is cloud agnostic. Develop once, then deploy anywhere.


The Essential

The two minutes video shows you how to create an Azure Container Instance from a SCR image and how to score the SAS model inside, using curl.



The shade highlights the components discussed in this post. (Drawing credits: Deva Kumar).



Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.



The scenario assumes you published a SAS model, with SCR, as a container image, to an Azure Container Registry (ACR). You can read more about the required configuration in How to Publish a SAS Model to Azure with SCR: A Start-to-Finish Guide.  



In the Azure Container Registry (ACR), named modelmanager, you can see two repositories, containing SCR images:

  • Qs_tree1 – is the champion model (a decision tree).
  • Qs_reg1 – is the challenger model (a logistic regression).




When you drill-down into the individual image (model) and tag (version), you will notice the SCR container image can be pulled with a simple docker command.  




To score the model inside the image:

  • Create an Azure Container Instance from the image (Azure Container Registry repository)
  • Score the model, using a simple command (curl)


Create an Azure Container Instance for a model

In the video, a container instance was created, for the champion model, called qs_tree1. To score the model, you will need these elements:

  1. The container instance created and the container is running.
  2. The FQDN or the public IP address of the container instance.




  1. The name of the model (also called module), qs_tree1, running inside the container.



  1. The port on which the container is listening. For SCR containers, this is 8080. You can see it in the container log.


  1. 250-bt_6_SAS-Container-Runtime-Model-Running-in-an-Azure-Container-Instance-Log-1024x488.png



Model Scoring Command

From a functional perspective, the model is classifying if the home loan application is likely to default, or not. The input data is for a home loan application. You will recognize without doubt, the structure of the famous HMEQ data set. The data section contains one data record, in json format.  


To score the model you can write a simple curl command, from a Linux machine. The machine must be able (and allowed) to reach the Azure container instance. 


curl --location --request POST ''  --header 'Content-Type: application/json'  --header 'Accept: application/json'  --data ' {
    "inputs": [
        { "name": "CLAGE", "value": 94.36666667 },
        { "name": "CLNO", "value": 9 },
        { "name": "DEBTINC", "value": 0 },
        { "name": "DELINQ", "value": 0 },
        { "name": "DEROG", "value": 0 },
        { "name": "JOB", "value": "Other" },
        { "name": "LOAN", "value": 0 },
        { "name": "MORTDUE", "value": 25860 },
        { "name": "NINQ", "value": 1 },
        { "name": "REASON", "value": "HomeImp" },
        { "name": "VALUE", "value": 39025 },
        { "name": "YOJ", "value": 10.5 }
} '


To format the json response, you can use jq, a JSON processor. Just add at the end:


 | jq


so that you have:


} ' | jq


Model Scoring Response

The response of the model score comes back in .json format.




In plain language, the model determines a 94% probability of no default on this home loan, and assigns I_BAD = 0, the predicted class.  


Container Activity

In the Azure portal, you can watch the container activity: every curl request creates a spike. You can look at the container logs, connect and explore the container folders, set alerts and so on.






If you publish a new model version from SAS, you need to redeploy your container instance.


The ACR keeps track of the published versions. The :latest tag is associated with the last version published ( such as 2.0, 3.0, etc.). The number is the model version in SAS Model Manager, from when you published the model to Azure.



All the credits go to my colleague Deva Kumar. Thank you for teaching me how to score a model in Azure.



It is quite easy to create a container instance in Azure, from a SCR container image. Then, you can score the model using a simple curl command.


Additional Resources

SAS documentation

SAS Communities and YouTube


Thank you for your time reading this article. If you liked the post, 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.

Version history
Last update:
‎10-31-2021 09:24 PM
Updated by:



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. 

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