About this sample
Before you begin
Run this sample
Sample details
Related links
This is a sample R app, which takes two whole numbers as input and returns the sum of squares (a^2 + b^2). The code for this sample is in sum_of_squares.R. The inputs and outputs are shown below.
| Parameter | Description |
|---|---|
a |
The first whole number |
b |
The second whole number |
| Parameter | Description |
|---|---|
result |
The result of calculating a^2 + b^2 |
To run this sample, you need the following prerequisites.
Software prerequisites:
- SQL Server big data cluster CTP 2.3 or later.
azdata. Refer to installing azdata document on setting up theazdataand connecting to a SQL Server 2019 big data cluster.
-
Clone or download this sample on your computer.
-
Log in to the SQL Server big data cluster using the command below using the IP address of the
controller-svc-externalin your cluster. If you are not familiar withazdatayou can refer to the documentation and then return to this sample.azdata login -e https://<ip-address-of-controller-svc-external>:30080 -u <user-name>
-
Deploy the application by running the following command, specifying the folder where your
spec.yamlandsum_of_squares.Rfiles are located:azdata app create --spec ./sumofsq
-
Check the deployment by running the following command:
azdata app list -n sum-of-sq -v [version]
Once the app is listed as
Readyyou can continue to the next step. -
Test the app by running the following command:
azdata app run -n sum-of-sq -v [version] --input a=42,b=3435
You should get output like the example below. The answer to your question are returned as
result.{ "changedFiles": [], "consoleOutput": "", "errorMessage": "", "outputFiles": {}, "outputParameters": { "result": 11800989.0 }, "success": true }RESTful web service. Note that any app you create is also accessible using a RESTful web service that is Swagger compliant. See step 6 in the Addpy sample for detailed instructions on how to call the web service.
-
You can clean up the sample by running the following commands:
# delete app azdata app delete --name sum-of-sq --version [version]
Please refer to sum_of_squares.R for the code for this sample.
Here is the spec file for this application. As you can see the sample uses the R runtime and calls the sofsq method in the sum_of_squares.R file, accepting two integer inputs named a and b and returning an integer output named result.
name: sum-of-sq
version: v1
runtime: R
src: ./sum_of_squares.R
entrypoint: sofsq
replicas: 1
poolsize: 1
inputs:
a: integer
b: integer
output:
result: integerFor more information, see these articles: