You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/virtual-machines/extensions/custom-script-linux.md
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ The Custom Script Extension integrates with Azure Resource Manager templates. Yo
20
20
This article details how to use the Custom Script Extension from the Azure CLI, and how to run the extension by using an Azure Resource Manager template. This article also provides troubleshooting steps for Linux systems.
21
21
22
22
There are two Linux Custom Script Extensions:
23
+
23
24
* Version 1: Microsoft.OSTCExtensions.CustomScriptForLinux
24
25
* Version 2: Microsoft.Azure.Extensions.CustomScript
25
26
@@ -175,14 +176,16 @@ For example, the following script is saved to the file */script.sh/*:
175
176
176
177
```sh
177
178
#!/bin/sh
178
-
echo"Updating packages ..."
179
-
apt update
180
-
apt upgrade -y
179
+
echo"Creating directories ..."
180
+
mkdir /data
181
+
chown user:user /data
182
+
mkdir /appdata
183
+
chown user:user /appdata
181
184
```
182
185
183
186
You would construct the correct Custom Script Extension script setting by taking the output of the following command:
184
187
185
-
```sh
188
+
```bash
186
189
cat script.sh | base64 -w0
187
190
```
188
191
@@ -194,7 +197,7 @@ cat script.sh | base64 -w0
194
197
195
198
In most cases, the script can optionally be gzip'ed to further reduce size. The Custom Script Extension automatically detects the use of gzip compression.
196
199
197
-
```sh
200
+
```bash
198
201
cat script | gzip -9 | base64 -w 0
199
202
```
200
203
@@ -238,6 +241,7 @@ To use the user-assigned identity on the target VM or virtual machine scale set,
@@ -250,8 +254,8 @@ To use the user-assigned identity on the target VM or virtual machine scale set,
250
254
> The `managedIdentity` property *must not* be used in conjunction with the `storageAccountName` or `storageAccountKey` property.
251
255
252
256
## Template deployment
253
-
You can deploy Azure VM extensions by using Azure Resource Manager templates. The JSON schema detailed in the previous section can be used in an Azure Resource Manager template to run the Custom Script Extension during the template's deployment. You can find a sample template that includes the Custom Script Extension on [GitHub](https://github.com/Azure/azure-quickstart-templates/blob/b1908e74259da56a92800cace97350af1f1fc32b/mongodb-on-ubuntu/azuredeploy.json/).
254
257
258
+
You can deploy Azure VM extensions by using Azure Resource Manager templates. The JSON schema detailed in the previous section can be used in an Azure Resource Manager template to run the Custom Script Extension during the template's deployment. You can find a sample template that includes the Custom Script Extension on [GitHub](https://github.com/Azure/azure-quickstart-templates/blob/b1908e74259da56a92800cace97350af1f1fc32b/mongodb-on-ubuntu/azuredeploy.json/).
255
259
256
260
```json
257
261
{
@@ -386,13 +390,13 @@ We recommend that you use [PowerShell](/powershell/module/az.Compute/Add-azVmssE
386
390
When the Custom Script Extension runs, the script is created or downloaded into a directory that's similar to the following example. The command output is also saved into this directory in `stdout` and `stderr` files.
387
391
388
392
```bash
389
-
/var/lib/waagent/custom-script/download/0/
393
+
sudo ls -l /var/lib/waagent/custom-script/download/0/
390
394
```
391
395
392
396
To troubleshoot, first check the Linux Agent Log and ensure that the extension ran:
393
397
394
398
```bash
395
-
/var/log/waagent.log
399
+
sudo cat /var/log/waagent.log
396
400
```
397
401
398
402
Look for the extension execution. It will look something like:
@@ -413,11 +417,10 @@ In the preceding output:
413
417
-`Enable` is when the command starts running.
414
418
-`Download` relates to the downloading of the Custom Script Extension package from Azure, not the script files specified in `fileUris`.
415
419
416
-
417
420
The Azure Script Extension produces a log, which you can find here:
418
421
419
422
```bash
420
-
/var/log/azure/custom-script/handler.log
423
+
sudo cat /var/log/azure/custom-script/handler.log
421
424
```
422
425
423
426
Look for the individual execution. It will look something like:
0 commit comments