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-linuxOstc.md
+52-39Lines changed: 52 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Run custom scripts on Linux VMs in Azure | Microsoft Docs
3
3
description: Automate Linux VM configuration tasks by using the Custom Script Extension v1
4
4
services: virtual-machines-linux
5
5
documentationcenter: ''
6
-
author: zroiy
6
+
author: danielsollondon
7
7
manager: jeconnoc
8
8
editor: ''
9
9
tags: azure-resource-manager
@@ -14,62 +14,65 @@ ms.devlang: na
14
14
ms.topic: article
15
15
ms.tgt_pltfrm: vm-linux
16
16
ms.workload: infrastructure-services
17
-
ms.date: 04/25/2018
18
-
ms.author: roiyz
17
+
ms.date: 08/14/2018
18
+
ms.author: danis
19
19
20
20
---
21
21
# 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.
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.
23
26
24
27
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.
25
28
26
29
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.
27
30
28
-
29
31
There are two Linux Custom Script Extensions:
32
+
30
33
* Version 1 - Microsoft.OSTCExtensions.CustomScriptForLinux
31
-
* Version 2 - Microsoft.Azure.Extensions.CustomScript
32
34
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
34
36
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.
36
38
37
39
### Operating System
40
+
38
41
Supported Linux Distributions:
39
42
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
48
51
49
52
### Script Location
50
53
51
54
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.
52
55
53
56
### 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).
55
59
56
60
If your script is on a local server, then you may still need additional firewall/Network Security Group ports need to be opened.
57
61
58
62
### Tips and Tricks
63
+
59
64
* 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.
60
65
* Write scripts that are idempotent, so if they get run again more than once accidentally, it will not cause system changes.
61
66
* Ensure the scripts do not require user input when they run.
62
67
* There is 90 mins allowed for the script to run, anything longer will result in a failed provision of the extension.
63
68
* 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.
64
69
* 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.
67
72
* 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*.
69
74
* Be aware of non default directory locations that your scripts or commands may rely on, have logic to handle this.
70
75
71
-
72
-
73
76
## Extension schema
74
77
75
78
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
*`fileUris`: (optional, string array) the uri list of the scripts
129
133
*`enableInternalDNSCheck`: (optional, bool) default is True, set to False to disable DNS check.
130
134
*`commandToExecute`: (optional, string) the entrypoint script to execute
131
135
*`storageAccountName`: (optional, string) the name of storage account
132
136
*`storageAccountKey`: (optional, string) the access key of storage account
133
137
134
138
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
+
135
140
*`commandToExecute`
136
141
137
142
Using public settings maybe useful for debugging, but it is strongly recommended that you use protected settings.
138
143
139
144
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.
140
145
141
-
142
146
## 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.
144
147
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.
145
149
146
150
```json
147
151
{
@@ -176,6 +180,7 @@ Azure VM extensions can be deployed with Azure Resource Manager templates. The J
176
180
>These property names are case-sensitive. To avoid deployment problems, use the names as shown here.
177
181
178
182
## Azure CLI
183
+
179
184
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'.
180
185
181
186
```azurecli
@@ -241,7 +246,7 @@ Protected configuration file:
241
246
Azure CLI command:
242
247
243
248
```azurecli
244
-
az vm extension set
249
+
az vm extension set
245
250
--resource-group myResourceGroup \
246
251
--vm-name myVM \
247
252
--name CustomScriptForLinux \
@@ -251,7 +256,8 @@ az vm extension set
251
256
```
252
257
253
258
## 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.
To see the code, current issues and versions, see [CustomScript Extension repo](https://github.com/Azure/azure-linux-extensions/tree/master/CustomScript).
343
355
356
+
To see the code, current issues and versions, see [CustomScript Extension repo](https://github.com/Azure/azure-linux-extensions/tree/master/CustomScript).
0 commit comments