Skip to content

Commit 3238b4e

Browse files
Merge pull request #232314 from divargas-msft/patch-7
[Doc-a-thon] Updating custom-script-linux to make it OS agnostic
2 parents 239a38e + 2531af2 commit 3238b4e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

articles/virtual-machines/extensions/custom-script-linux.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The Custom Script Extension integrates with Azure Resource Manager templates. Yo
2020
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.
2121

2222
There are two Linux Custom Script Extensions:
23+
2324
* Version 1: Microsoft.OSTCExtensions.CustomScriptForLinux
2425
* Version 2: Microsoft.Azure.Extensions.CustomScript
2526

@@ -175,14 +176,16 @@ For example, the following script is saved to the file */script.sh/*:
175176

176177
```sh
177178
#!/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
181184
```
182185

183186
You would construct the correct Custom Script Extension script setting by taking the output of the following command:
184187

185-
```sh
188+
```bash
186189
cat script.sh | base64 -w0
187190
```
188191

@@ -194,7 +197,7 @@ cat script.sh | base64 -w0
194197

195198
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.
196199

197-
```sh
200+
```bash
198201
cat script | gzip -9 | base64 -w 0
199202
```
200203

@@ -238,6 +241,7 @@ To use the user-assigned identity on the target VM or virtual machine scale set,
238241
> "managedIdentity" : { "clientId": "31b403aa-c364-4240-a7ff-d85fb6cd7232" }
239242
> }
240243
> ```
244+
241245
> ```json
242246
> {
243247
> "fileUris": ["https://mystorage.blob.core.windows.net/privatecontainer/script1.sh"],
@@ -250,8 +254,8 @@ To use the user-assigned identity on the target VM or virtual machine scale set,
250254
> The `managedIdentity` property *must not* be used in conjunction with the `storageAccountName` or `storageAccountKey` property.
251255
252256
## 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/).
254257
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/).
255259
256260
```json
257261
{
@@ -386,13 +390,13 @@ We recommend that you use [PowerShell](/powershell/module/az.Compute/Add-azVmssE
386390
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.
387391

388392
```bash
389-
/var/lib/waagent/custom-script/download/0/
393+
sudo ls -l /var/lib/waagent/custom-script/download/0/
390394
```
391395

392396
To troubleshoot, first check the Linux Agent Log and ensure that the extension ran:
393397

394398
```bash
395-
/var/log/waagent.log
399+
sudo cat /var/log/waagent.log
396400
```
397401

398402
Look for the extension execution. It will look something like:
@@ -413,11 +417,10 @@ In the preceding output:
413417
- `Enable` is when the command starts running.
414418
- `Download` relates to the downloading of the Custom Script Extension package from Azure, not the script files specified in `fileUris`.
415419

416-
417420
The Azure Script Extension produces a log, which you can find here:
418421

419422
```bash
420-
/var/log/azure/custom-script/handler.log
423+
sudo cat /var/log/azure/custom-script/handler.log
421424
```
422425

423426
Look for the individual execution. It will look something like:

0 commit comments

Comments
 (0)