|
| 1 | +--- |
| 2 | +title: How to deploy an app on SQL Server big data cluster | Microsoft Docs |
| 3 | +description: Deploy a Python or R script as an application on SQL Server 2019 big data cluster (preview). |
| 4 | +author: TheBharath |
| 5 | +ms.author: bharaths |
| 6 | +manager: craigg |
| 7 | +ms.date: 11/06/2018 |
| 8 | +ms.topic: conceptual |
| 9 | +ms.prod: sql |
| 10 | +--- |
| 11 | + |
| 12 | +# How to deploy an app on SQL Server 2019 big data cluster (preview) |
| 13 | + |
| 14 | +This article describes how to deploy and manage R and Python script as an application inside a SQL Server 2019 big data cluster (preview). |
| 15 | + |
| 16 | +R and Python applications are deployed and managed with the **mssqlctl-pre** command-line utility which is included in CTP 2.1. This article provides examples of how to deploy these R and Python scripts as apps from the command line. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +You must have a SQL Server 2019 big data cluster configured. For more information, see [How to deploy SQL Server big data cluster on Kubernetes](deployment-guidance.md). |
| 21 | + |
| 22 | +## Installation |
| 23 | + |
| 24 | +The **mssqlctl-pre** command-line utility is provided to preview the Python and R application deployment feature. Use the following command to install the utility: |
| 25 | + |
| 26 | +```cmd |
| 27 | +pip3 install --extra-index-url https://private-repo.microsoft.com/python/ctp-2.1 mssqlctl-pre |
| 28 | +``` |
| 29 | + |
| 30 | +## Capabilities |
| 31 | + |
| 32 | +In CTP 2.1 you can create, delete, list, and run an R or Python application. The following table describes the application deployment commands that you can use with **mssqlctl-pre**. |
| 33 | + |
| 34 | +| Command | Description | |
| 35 | +|---|---| |
| 36 | +| `mssqlctl-pre login` | Log into a SQL Server big data cluster | |
| 37 | +| `mssqlctl-pre app create` | Create an app | |
| 38 | +| `mssqlctl-pre app list` | List deployed apps | |
| 39 | +| `mssqlctl-pre app delete` | Delete an app | |
| 40 | +| `mssqlctl-pre app run` | List running apps | |
| 41 | + |
| 42 | +You can get help with the `--help` parameter as in the following example: |
| 43 | + |
| 44 | +```bash |
| 45 | +mssqlctl-pre app create --help |
| 46 | +``` |
| 47 | + |
| 48 | +The following sections describe these commands in more detail. |
| 49 | + |
| 50 | +## Log in |
| 51 | + |
| 52 | +Before configuring R and Python applications, first log into your SQL Server big data cluster with the `mssqlctl-pre login` command. Specify the IP address of the `service-proxy-lb` (for example: `https://ip-address:30777`) along with the user name and password to the cluster. |
| 53 | + |
| 54 | +You can get the IP address of the service-proxy-lb service by running this command in a bash or cmd window: |
| 55 | +```bash |
| 56 | +kubectl get svc service-proxy-lb:30777 -n <name of your cluster> |
| 57 | +``` |
| 58 | + |
| 59 | +```bash |
| 60 | +mssqlctl-pre login -e https://<ip-address-of-service-proxy-lb> -u <user-name> -p <password> |
| 61 | +``` |
| 62 | + |
| 63 | +## Create an app |
| 64 | + |
| 65 | +To create an application, you pass Python or R code files to **mssqlctl-pre** with the `app create` command. These files reside locally on the machine that you are creating the app from. |
| 66 | + |
| 67 | +Use the following syntax to create a new app in your big data cluster: |
| 68 | + |
| 69 | +```bash |
| 70 | +mssqlctl-pre app create -n <app_name> -v <version_number> -r <runtime> -i <path_to_code_init> -c <path_to_code> --inputs <input_params> --outputs <output_params> |
| 71 | +``` |
| 72 | + |
| 73 | +The following command shows an example of what this command might look like: |
| 74 | + |
| 75 | +```py |
| 76 | +#add.py |
| 77 | +def add(x,y): |
| 78 | + result = x+y |
| 79 | + return result; |
| 80 | +result=add(x,y) |
| 81 | +``` |
| 82 | +To try this, save the above lines of code to your local directory as `add.py` and run the command below |
| 83 | + |
| 84 | +```bash |
| 85 | +mssqlctl-pre app create --name add-app --version v1 --runtime Python --code ./add.py --inputs x=int,y=int --outputs result=int |
| 86 | +``` |
| 87 | + |
| 88 | +You can check if the app is deployed using the list command: |
| 89 | + |
| 90 | +```bash |
| 91 | +mssqlctl-pre app list |
| 92 | +``` |
| 93 | + |
| 94 | +If the deployment is not complete you should see the "state" show "Creating": |
| 95 | + |
| 96 | +``` |
| 97 | +[ |
| 98 | + { |
| 99 | + "name": "add-app", |
| 100 | + "state": "Creating", |
| 101 | + "version": "v1" |
| 102 | + } |
| 103 | +] |
| 104 | +``` |
| 105 | + |
| 106 | +After the deployment is successful you should see the "state" change to "Ready" status: |
| 107 | + |
| 108 | +``` |
| 109 | +[ |
| 110 | + { |
| 111 | + "name": "add-app", |
| 112 | + "state": "Ready", |
| 113 | + "version": "v1" |
| 114 | + } |
| 115 | +] |
| 116 | +``` |
| 117 | + |
| 118 | +## List an app |
| 119 | + |
| 120 | +You can list any apps that were successfully created with the `app list` command. |
| 121 | + |
| 122 | +The following command lists all available applications in your big data cluster: |
| 123 | + |
| 124 | +```bash |
| 125 | +mssqlctl-pre app list |
| 126 | +``` |
| 127 | + |
| 128 | +If you specify a name and version, it will list that specific app and its state (Creating or Ready): |
| 129 | + |
| 130 | +```bash |
| 131 | +mssqlctl-pre app list --name <app_name> --version <app_version> |
| 132 | +``` |
| 133 | + |
| 134 | +The following example demonstrates this command: |
| 135 | + |
| 136 | +```bash |
| 137 | +mssqlctl-pre app list --name add-app --version v1 |
| 138 | +``` |
| 139 | + |
| 140 | +You should see output similar to the following example: |
| 141 | + |
| 142 | +``` |
| 143 | +[ |
| 144 | + { |
| 145 | + "name": "add-app", |
| 146 | + "state": "Ready", |
| 147 | + "version": "v1" |
| 148 | + } |
| 149 | +] |
| 150 | +``` |
| 151 | + |
| 152 | +## Run an app |
| 153 | + |
| 154 | +If the app is in a "Ready" state, you can use it by running it with your specified input parameters. Use the following syntax to run an app: |
| 155 | + |
| 156 | +```bash |
| 157 | +mssqlctl-pre app run --name <app_name> --version <app_version> --inputs <inputs_params> |
| 158 | +``` |
| 159 | + |
| 160 | +The following example command demonstrates the run command: |
| 161 | + |
| 162 | +```bash |
| 163 | +mssqlctl-pre app run --name add-app --version v1 --inputs x=1,y=2 |
| 164 | +``` |
| 165 | + |
| 166 | +If the run was successful, you should see your output as specified when you created the app. The following is an example. |
| 167 | + |
| 168 | +``` |
| 169 | +{ |
| 170 | + "changedFiles": [], |
| 171 | + "consoleOutput": "", |
| 172 | + "errorMessage": "", |
| 173 | + "outputFiles": {}, |
| 174 | + "outputParameters": { |
| 175 | + "result": 3 |
| 176 | + }, |
| 177 | + "success": true |
| 178 | +} |
| 179 | +``` |
| 180 | + |
| 181 | +## Delete an app |
| 182 | + |
| 183 | +To delete an app from your big data cluster, use the following syntax: |
| 184 | + |
| 185 | +```bash |
| 186 | +mssqlctl-pre app delete --name add-app --version v1 |
| 187 | +``` |
| 188 | + |
| 189 | +## Next steps |
| 190 | + |
| 191 | +You can also check out additional samples at [https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/sql-big-data-cluster](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/sql-big-data-cluster). |
| 192 | + |
| 193 | +For more information about SQL Server big data clusters, see [What are SQL Server 2019 big data clusters?](big-data-cluster-overview.md). |
0 commit comments