Skip to content

Commit 88f30b6

Browse files
committed
Merge branch 'master' of https://github.com/MicrosoftDocs/azure-docs-pr into 1313082-3
2 parents 3d060bb + fa58f91 commit 88f30b6

File tree

2 files changed

+54
-41
lines changed

2 files changed

+54
-41
lines changed

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

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Run custom scripts on Linux VMs in Azure | Microsoft Docs
33
description: Automate Linux VM configuration tasks by using the Custom Script Extension v1
44
services: virtual-machines-linux
55
documentationcenter: ''
6-
author: zroiy
6+
author: danielsollondon
77
manager: jeconnoc
88
editor: ''
99
tags: azure-resource-manager
@@ -14,62 +14,65 @@ ms.devlang: na
1414
ms.topic: article
1515
ms.tgt_pltfrm: vm-linux
1616
ms.workload: infrastructure-services
17-
ms.date: 04/25/2018
18-
ms.author: roiyz
17+
ms.date: 08/14/2018
18+
ms.author: danis
1919

2020
---
2121
# Use the Azure Custom Script Extension Version 1 with Linux virtual machines
22-
The Custom Script Extension Version 1 downloads and runs scripts on Azure virtual machines. This extension is useful for post-deployment configuration, software installation, or any other configuration/management task. You can download scripts from Azure Storage or another accessible internet location, or you can provide them to the extension runtime.
22+
23+
[!INCLUDE [virtual-machines-extensions-deprecation-statement](../../../includes/virtual-machines-extensions-deprecation-statement.md)]
24+
25+
The Custom Script Extension Version 1 downloads and runs scripts on Azure virtual machines. This extension is useful for post-deployment configuration, software installation, or any other configuration/management task. You can download scripts from Azure Storage or another accessible internet location, or you can provide them to the extension runtime.
2326

2427
The Custom Script Extension integrates with Azure Resource Manager templates. You can also run it by using Azure CLI, PowerShell, the Azure portal, or the Azure Virtual Machines REST API.
2528

2629
This article details how to use the Custom Script Extension from Azure CLI, and how to run the extension by using an Azure Resource Manager template. This article also provides troubleshooting steps for Linux systems.
2730

28-
2931
There are two Linux Custom Script Extensions:
32+
3033
* Version 1 - Microsoft.OSTCExtensions.CustomScriptForLinux
31-
* Version 2 - Microsoft.Azure.Extensions.CustomScript
3234

33-
Please switch new and existing deployments to use the new version ([Microsoft.Azure.Extensions.CustomScript](https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux)) instead. The new version is intended to be a drop-in replacement. Therefore, the migration is as easy as changing the name and version, you do not need to change your extension configuration.
35+
* Version 2 - Microsoft.Azure.Extensions.CustomScript
3436

35-
37+
Please switch new and existing deployments to use the new version ([Microsoft.Azure.Extensions.CustomScript](custom-script-linux.md)) instead. The new version is intended to be a drop-in replacement. Therefore, the migration is as easy as changing the name and version, you do not need to change your extension configuration.
3638

3739
### Operating System
40+
3841
Supported Linux Distributions:
3942

40-
- CentOS 6.5 and higher
41-
- Debian 8 and higher
42-
- Debian 8.7 does not ship with Python2 in the latest images, which breaks CustomScriptForLinux.
43-
- FreeBSD
44-
- OpenSUSE 13.1 and higher
45-
- Oracle Linux 6.4 and higher
46-
- SUSE Linux Enterprise Server 11 SP3 and higher
47-
- Ubuntu 12.04 and higher
43+
* CentOS 6.5 and higher
44+
* Debian 8 and higher
45+
* Debian 8.7 does not ship with Python2 in the latest images, which breaks CustomScriptForLinux.
46+
* FreeBSD
47+
* OpenSUSE 13.1 and higher
48+
* Oracle Linux 6.4 and higher
49+
* SUSE Linux Enterprise Server 11 SP3 and higher
50+
* Ubuntu 12.04 and higher
4851

4952
### Script Location
5053

5154
You can use the extension to use your Azure Blob storage credentials, to access Azure Blob storage. Alternatively, the script location can be any where, as long as the VM can route to that end point, such as GitHub, internal file server etc.
5255

5356
### Internet Connectivity
54-
If you need to download a script externally such as GitHub or Azure Storage, then additional firewall/Network Security Group ports need to be opened. For example if your script is located in Azure Storage, you can allow access using Azure NSG Service Tags for [Storage](https://docs.microsoft.com/en-us/azure/virtual-network/security-overview#service-tags).
57+
58+
If you need to download a script externally such as GitHub or Azure Storage, then additional firewall/Network Security Group ports need to be opened. For example if your script is located in Azure Storage, you can allow access using Azure NSG Service Tags for [Storage](../../virtual-network/security-overview.md#service-tags).
5559

5660
If your script is on a local server, then you may still need additional firewall/Network Security Group ports need to be opened.
5761

5862
### Tips and Tricks
63+
5964
* The highest failure rate for this extension is due to syntax errors in the script, test the script runs without error, and also put in additional logging into the script to make it easier to find where it failed.
6065
* Write scripts that are idempotent, so if they get run again more than once accidentally, it will not cause system changes.
6166
* Ensure the scripts do not require user input when they run.
6267
* There is 90 mins allowed for the script to run, anything longer will result in a failed provision of the extension.
6368
* Do not put reboots inside the script, this will cause issues with other extensions that are being installed, and post reboot, the extension will not continue after the restart.
6469
* If you have a script that will cause a reboot, then install applications and run scripts etc. You should schedule the reboot using a Cron job, or using tools such as DSC, or Chef, Puppet extensions.
65-
* The extension will only run a script once, if you want to run a script on every boot, then you can use [cloud-init image](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init) and use a [Scripts Per Boot](https://cloudinit.readthedocs.io/en/latest/topics/modules.html#scripts-per-boot) module. Alternatively, you can use the script to create a Systemd service unit.
66-
* If you want to schedule when a script will run, you should use the extension to create a Cron job.
70+
* The extension will only run a script once, if you want to run a script on every boot, then you can use [cloud-init image](../linux/using-cloud-init.md) and use a [Scripts Per Boot](https://cloudinit.readthedocs.io/en/latest/topics/modules.html#scripts-per-boot) module. Alternatively, you can use the script to create a Systemd service unit.
71+
* If you want to schedule when a script will run, you should use the extension to create a Cron job.
6772
* When the script is running, you will only see a 'transitioning' extension status from the Azure portal or CLI. If you want more frequent status updates of a running script, you will need to create your own solution.
68-
* Custom Script extension does not natively support proxy servers, however you can use a file transfer tool that supports proxy servers within your script, such as *Curl*.
73+
* Custom Script extension does not natively support proxy servers, however you can use a file transfer tool that supports proxy servers within your script, such as *Curl*.
6974
* Be aware of non default directory locations that your scripts or commands may rely on, have logic to handle this.
7075

71-
72-
7376
## Extension schema
7477

7578
The Custom Script Extension configuration specifies things like script location and the command to be run. You can store this configuration in configuration files, specify it on the command line, or specify it in an Azure Resource Manager template.
@@ -112,36 +115,37 @@ These items should be treated as sensitive data and specified in the extensions
112115

113116
### Property values
114117

115-
| Name | Value / Example | Data Type |
118+
| Name | Value / Example | Data Type |
116119
| ---- | ---- | ---- |
117120
| apiVersion | 2015-06-15 | date |
118121
| publisher | Microsoft.OSTCExtensions | string |
119122
| type | CustomScriptForLinux | string |
120123
| typeHandlerVersion | 1.5 | int |
121124
| fileUris (e.g) | https://github.com/MyProject/Archive/MyPythonScript.py | array |
122-
| commandToExecute (e.g) | python MyPythonScript.py <my-param1> | string |
125+
| commandToExecute (e.g) | python MyPythonScript.py \<my-param1\> | string |
123126
| enableInternalDNSCheck | true | boolean |
124127
| storageAccountName (e.g) | examplestorageacct | string |
125128
| storageAccountKey (e.g) | TmJK/1N3AbAZ3q/+hOXoi/l73zOqsaxXDhqa9Y83/v5UpXQp2DQIBuv2Tifp60cE/OaHsJZmQZ7teQfczQj8hg== | string |
126129

127130
### Property value details
131+
128132
* `fileUris`: (optional, string array) the uri list of the scripts
129133
* `enableInternalDNSCheck`: (optional, bool) default is True, set to False to disable DNS check.
130134
* `commandToExecute`: (optional, string) the entrypoint script to execute
131135
* `storageAccountName`: (optional, string) the name of storage account
132136
* `storageAccountKey`: (optional, string) the access key of storage account
133137

134138
The following values can be set in either public or protected settings, you must not have these values below set in both public and protected settings.
139+
135140
* `commandToExecute`
136141

137142
Using public settings maybe useful for debugging, but it is strongly recommended that you use protected settings.
138143

139144
Public settings are sent in clear text to the VM where the script will be executed. Protected settings are encrypted using a key known only to the Azure and the VM. The settings are saved to the VM as they were sent, i.e. if the settings were encrypted they are saved encrypted on the VM. The certificate used to decrypt the encrypted values is stored on the VM, and used to decrypt settings (if necessary) at runtime.
140145

141-
142146
## Template deployment
143-
Azure VM extensions can be deployed with 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 an Azure Resource Manager template deployment.
144147

148+
Azure VM extensions can be deployed with 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 an Azure Resource Manager template deployment.
145149

146150
```json
147151
{
@@ -176,6 +180,7 @@ Azure VM extensions can be deployed with Azure Resource Manager templates. The J
176180
>These property names are case-sensitive. To avoid deployment problems, use the names as shown here.
177181
178182
## Azure CLI
183+
179184
When you're using Azure CLI to run the Custom Script Extension, create a configuration file or files. At a minimum, you must have 'commandToExecute'.
180185

181186
```azurecli
@@ -241,7 +246,7 @@ Protected configuration file:
241246
Azure CLI command:
242247

243248
```azurecli
244-
az vm extension set
249+
az vm extension set
245250
--resource-group myResourceGroup \
246251
--vm-name myVM \
247252
--name CustomScriptForLinux \
@@ -251,7 +256,8 @@ az vm extension set
251256
```
252257

253258
## Troubleshooting
254-
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.
259+
260+
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.
255261

256262
```bash
257263
/var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-<version>/download/1
@@ -260,10 +266,11 @@ When the Custom Script Extension runs, the script is created or downloaded into
260266
To troubleshoot, first check the Linux Agent Log, ensure the extension ran, check:
261267

262268
```bash
263-
/var/log/waagent.log
269+
/var/log/waagent.log
264270
```
265271

266272
You should look for the extension execution, it will look something like:
273+
267274
```text
268275
2018/04/26 15:29:44.835067 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] Target handler state: enabled
269276
2018/04/26 15:29:44.867625 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] [Enable] current handler state is: notinstalled
@@ -280,18 +287,22 @@ You should look for the extension execution, it will look something like:
280287
..
281288
2018/04/26 15:29:47.178163 INFO Event: name=Microsoft.OSTCExtensions.CustomScriptForLinux, op=Enable, message=Launch command succeeded: customscript.py -enable, duration=1012
282289
```
290+
283291
Some points to note:
292+
284293
1. Enable is when the command starts running.
285-
2. Download relates to the downloading of the CustomScript extension package from Azure, not the script files specified in fileUris.
286-
3. You can also see which log file it is writing out to, '/var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.5.2.2/extension.log
287-
'.
294+
1. Download relates to the downloading of the CustomScript extension package from Azure, not the script files specified in fileUris.
295+
1. You can also see which log file it is writing out to,`/var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.5.2.2/extension.log
296+
`
288297

289298
Next step is to go an check the log file, this is the format:
299+
290300
```bash
291301
/var/log/azure/<extension-name>/<version>/extension.log file.
292302
```
293303

294304
You should look for the induvidual execution, it will look something like:
305+
295306
```text
296307
2018/04/26 15:29:46 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] Enable,transitioning,0,Launching the script...
297308
2018/04/26 15:29:46 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] sequence number is 0
@@ -307,18 +318,20 @@ You should look for the induvidual execution, it will look something like:
307318
2018/04/26 15:29:46 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] Internal DNS is ready, retry count = 0
308319
2018/04/26 15:29:47 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] Command is finished.
309320
2018/04/26 15:29:47 ---stdout---
310-
2018/04/26 15:29:47
321+
2018/04/26 15:29:47
311322
2018/04/26 15:29:47 ---errout---
312-
2018/04/26 15:29:47
313-
2018/04/26 15:29:47
323+
2018/04/26 15:29:47
324+
2018/04/26 15:29:47
314325
2018/04/26 15:29:47 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2] Daemon,success,0,Command is finished.
315326
2018/04/26 15:29:47 ---stdout---
316-
2018/04/26 15:29:47
327+
2018/04/26 15:29:47
317328
2018/04/26 15:29:47 ---errout---
318-
2018/04/26 15:29:47
319-
2018/04/26 15:29:47
329+
2018/04/26 15:29:47
330+
2018/04/26 15:29:47
320331
```
332+
321333
Here you can see:
334+
322335
* The Enable command starting is this log
323336
* The settings passed to the extension
324337
* The extension downloading file and the result of that.
@@ -339,5 +352,5 @@ CustomScriptForLinux Succeeded Microsoft.OSTCExtensions 1.5
339352
```
340353

341354
## Next steps
342-
To see the code, current issues and versions, see [CustomScript Extension repo](https://github.com/Azure/azure-linux-extensions/tree/master/CustomScript).
343355

356+
To see the code, current issues and versions, see [CustomScript Extension repo](https://github.com/Azure/azure-linux-extensions/tree/master/CustomScript).

articles/virtual-machines/extensions/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
items:
3333
- name: Linux - version 2
3434
href: custom-script-linux.md
35-
- name: Linux - version 1 (OSTC)
36-
href: custom-script-linuxOstc.md
3735
- name: Windows
3836
href: custom-script-windows.md
3937
- name: Azure Service Management (Classic)
@@ -97,6 +95,8 @@
9795
href: log-collector.md
9896
- name: Trend Micro Deep Security
9997
href: trend.md
98+
- name: Linux - version 1 (OSTC)
99+
href: custom-script-linuxOstc.md
100100
- name: Restrict extension installation
101101
items:
102102
- name: Linux

0 commit comments

Comments
 (0)