|
| 1 | +--- |
| 2 | +title: Configure autoscale settings for a Stream Analytics job using ASA CI/CD tool |
| 3 | +description: This article shows how to configure autoscale settings for a Stream Analytics job using ASA CI/CD tool. |
| 4 | +services: stream-analytics |
| 5 | +author: alexlzx |
| 6 | +ms.author: zhenxilin |
| 7 | +ms.service: stream-analytics |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 02/08/2023 |
| 10 | +--- |
| 11 | + |
| 12 | +# Configure autoscale settings for a Stream Analytics job using ASA CI/CD tool |
| 13 | + |
| 14 | +Streaming units (SUs) represent the computing resources that are allocated to execute a Stream Analytics job. The higher the number of SUs, the more CPU and memory resources are allocated to your job. The autoscale feature dynamically adjust SUs based on your rule definitions. You can configure autoscale settings for your Stream Analytics job in the Azure portal or using ASA CI/CD tool in your local machine. |
| 15 | + |
| 16 | +This article explains how you can use ASA CI/CD tool to configure autoscale settings for Stream Analytics jobs. If you want to learn more about autoscaling jobs in the Azure portal, see [Autoscale streaming units (Preview)](stream-analytics-autoscale.md). |
| 17 | + |
| 18 | +The ASA CI/CD tool allows you to specify the maximum number of streaming units and configure set of rules for autoscaling your jobs. Then it determines to add SUs to handle increases in load or to reduce the number of SUs when computing resources are sitting idle. |
| 19 | + |
| 20 | +Examples of an autoscale setting: |
| 21 | +- If the maximum number of SUs is set to 12, it increases SUs when the average SU% utilization of the job over the last 2 minutes goes above 75%. |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | +- A Stream Analytics project in the local machine. If don't have one, follow this [guide](quick-create-visual-studio-code.md) to create one. |
| 25 | +- Or you have a running ASA job in Azure. |
| 26 | + |
| 27 | +## How to configure autoscale settings? |
| 28 | + |
| 29 | +### Scenario 1: configure for a local Stream Analytics project |
| 30 | + |
| 31 | +If you have a working Stream Analytics project in the local machine, follow the steps to configure autoscale settings: |
| 32 | + |
| 33 | +1. Open your Stream Analytics project in Visual Studio Code. |
| 34 | +2. On the **Terminal** panel, run the command to install ASA CI/CD tool. |
| 35 | + ```powershell |
| 36 | + npm install -g azure-streamanalytics-cicd |
| 37 | + ``` |
| 38 | + |
| 39 | + Here's the list of command supported for `azure-streamanalytics-cicd`: |
| 40 | +
|
| 41 | + |Command |Description | |
| 42 | + |---------------|---------------| |
| 43 | + |build |Generate standard ARM template for the given Azure Stream Analytics Visual Studio Code project.| |
| 44 | + |localrun |Run locally for the given Azure Stream Analytics Visual Studio Code project.| |
| 45 | + |test |Test for given Azure Stream Analytics Visual Studio Code project.| |
| 46 | + |addtestcase |Add test cases for the given Azure Stream Analytics Visual Studio Code project.| |
| 47 | + |autoscale |Generate autoscale setting ARM template file.| |
| 48 | + |help |Display more information on a specific command.| |
| 49 | +
|
| 50 | +3. Build project. |
| 51 | + ```powershell |
| 52 | + azure-streamanalytics-cicd build --v2 --project ./asaproj.json --outputPath ./Deploy |
| 53 | + ``` |
| 54 | +
|
| 55 | + If the project is built successfully, you see 2 JSON files created under **Deploy** folder. One is the ARM template file and the other one is the parameter file. |
| 56 | +
|
| 57 | +  |
| 58 | +
|
| 59 | + > [!NOTE] |
| 60 | + > It is highly recommended to use the `--v2` option for the updated ARM template schema, which has fewer parameters yet retains the same functionality as the previous version. The old ARM template will be deprecated in the future, and only templates created using `build --v2` will receive updates or bug fixes. |
| 61 | +
|
| 62 | +4. Configure autoscale setting. |
| 63 | + You need to add parameter keys and values using `azure-streamanalytics-cicd autoscale` command. |
| 64 | +
|
| 65 | + |Parameter key | Value | Example| |
| 66 | + |----------------|-------|--------| |
| 67 | + |capacity| maximum SUs (1, 3, 6 or multiples of 6 up to 396)|12| |
| 68 | + |metrics | metrics used for autoscale rules | ProcessCPUUsagePercentage ResourceUtilization| |
| 69 | + |targetJobName| project name| ClickStream-Filter| |
| 70 | + |outputPath| output path for ARM templates | ./Deploy| |
| 71 | + |
| 72 | + Example: |
| 73 | + ```powershell |
| 74 | + azure-streamanalytics-cicd autoscale --capacity 12 --metrics ProcessCPUUsagePercentage ResourceUtilization --targetJobName ClickStream-Filter --outputPath ./Deploy |
| 75 | + ``` |
| 76 | +
|
| 77 | + If the autoscale setting is configured successfully, you see 2 JSON files created under **Deploy** folder. One is the ARM template file and the other one is the parameter file. |
| 78 | +
|
| 79 | +  |
| 80 | +
|
| 81 | + Here's the list of metrics you can use for defining autoscale rules: |
| 82 | +
|
| 83 | + |Metrics | Description | |
| 84 | + |-------------------------------|-------------------| |
| 85 | + |ProcessCPUUsagePercentage | CPU % Utilization | |
| 86 | + |ResourceUtilization | SU/Memory % Utilization | |
| 87 | + |OutputWatermarkDelaySeconds | Watermark Delay | |
| 88 | + |InputEventsSourcesBacklogged | Backlogged Input Events | |
| 89 | + |DroppedOrAdjustedEvents | Out of order Events | |
| 90 | + |Errors | Runtime Errors | |
| 91 | + |InputEventBytes | Input Event Bytes | |
| 92 | + |LateInputEvents | Late Input Events | |
| 93 | + |InputEvents | Input Events | |
| 94 | + |EarlyInputEvents | Early Input Events | |
| 95 | + |InputEventsSourcesPerSecond | Input Sources Received | |
| 96 | + |OutputEvents | Output Events | |
| 97 | + |AMLCalloutRequests | Function Requests | |
| 98 | + |AMLCalloutFailedRequests | Failed Function Requests | |
| 99 | + |AMLCalloutInputEvents | Function Events | |
| 100 | + |ConversionErrors | Data Conversion Errors | |
| 101 | + |DeserializationError | Input Deserialization Errors | |
| 102 | +
|
| 103 | + The default value for all metric threshold is **70**. If you want to set the metric threshold to another number, open **\*.AutoscaleSettingTemplate.parameters.json** file and change the **Threshold** value. |
| 104 | +
|
| 105 | +  |
| 106 | + |
| 107 | + To learn more about defining autoscale rules, visit [here](https://learn.microsoft.com/azure/azure-monitor/autoscale/autoscale-understanding-settings). |
| 108 | + |
| 109 | +5. Deploy to Azure |
| 110 | + 1. Connect to Azure account. |
| 111 | + ```powershell |
| 112 | + # Connect to Azure |
| 113 | + Connect-AzAccount |
| 114 | +
|
| 115 | + # Set Azure subscription. |
| 116 | + Set-AzContext [SubscriptionID/SubscriptionName] |
| 117 | + ``` |
| 118 | + 1. Deploy your Stream Analytics project. |
| 119 | + ```powershell |
| 120 | + $templateFile = ".\Deploy\ClickStream-Filter.JobTemplate.json" |
| 121 | + $parameterFile = ".\Deploy\ClickStream-Filter.JobTemplate.parameters.json" |
| 122 | + New-AzResourceGroupDeployment ` |
| 123 | + -Name devenvironment ` |
| 124 | + -ResourceGroupName myResourceGroupDev ` |
| 125 | + -TemplateFile $templateFile ` |
| 126 | + -TemplateParameterFile $parameterFile |
| 127 | + ``` |
| 128 | + 1. Deploy your autoscale settings. |
| 129 | + ```powershell |
| 130 | + $templateFile = ".\Deploy\ClickStream-Filter.AutoscaleSettingTemplate.json" |
| 131 | + $parameterFile = ".\Deploy\ClickStream-Filter.AutoscaleSettingTemplate.parameters.json" |
| 132 | + New-AzResourceGroupDeployment ` |
| 133 | + -Name devenvironment ` |
| 134 | + -ResourceGroupName myResourceGroupDev ` |
| 135 | + -TemplateFile $templateFile ` |
| 136 | + -TemplateParameterFile $parameterFile |
| 137 | + ``` |
| 138 | +
|
| 139 | +Once your project is deployed successfully, you can view the autoscale settings in Azure portal. |
| 140 | +
|
| 141 | +
|
| 142 | +### Scenario 2: Configure for a running ASA job in Azure |
| 143 | +
|
| 144 | +If you have a Stream Analytics job running in Azure, you can use ASA CI/CD tool in the PowerShell to configure autoscale settings. |
| 145 | +
|
| 146 | +Replace **$jobResourceId** with your Stream Analytics job resource ID and run this command: |
| 147 | +```powershell |
| 148 | +azure-streamanalytics-cicd autoscale --capacity 12 --metrics ProcessCPUUsagePercentage ResourceUtilization --targetJobResourceId $jobResourceId --outputPath ./Deploy |
| 149 | +``` |
| 150 | + |
| 151 | +If configure successfully, you see ARM template and parameter files created in the current directory. |
| 152 | + |
| 153 | +Then you can deploy the autoscale settings to Azure by following the Deployment steps in scenario 1. |
| 154 | + |
| 155 | +## Help |
| 156 | + |
| 157 | +For more information about autoscale settings, run this command in PowerShell: |
| 158 | +```powershell |
| 159 | +azure-streamanalytics-cicd autoscale --help |
| 160 | +``` |
| 161 | + |
| 162 | +If you have any issues about the ASA CI/CD tool, you can report it [here](https://github.com/microsoft/vscode-asa/issues). |
0 commit comments