Skip to content

Commit b7d2da8

Browse files
Freshness pass.
1 parent 9daa1fb commit b7d2da8

File tree

1 file changed

+52
-9
lines changed

1 file changed

+52
-9
lines changed

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

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.date: 03/29/2023
1212
---
1313
# Use the Azure Custom Script Extension Version 2 with Linux virtual machines
1414

15-
The Custom Script Extension Version 2 downloads and runs scripts on Azure virtual machines (VMs). Use this for post-deployment configuration, software installation, or any other configuration or management task. You can download scripts from Azure Storage or another accessible internet location, or you can provide them to the extension runtime.
15+
The Custom Script Extension Version 2 downloads and runs scripts on Azure virtual machines (VMs). Use this extension for post-deployment configuration, software installation, or any other configuration or management task. You can download scripts from Azure Storage or another accessible internet location, or you can provide them to the extension runtime.
1616

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

@@ -305,14 +305,27 @@ az vm extension set \
305305

306306
### Example: Public configuration with script file
307307

308+
This example uses the following script file named *script-config.json*:
309+
308310
```json
309311
{
310312
"fileUris": ["https://raw.githubusercontent.com/Microsoft/dotnet-core-sample-templates/master/dotnet-core-music-linux/scripts/config-music.sh"],
311313
"commandToExecute": "./config-music.sh"
312314
}
313315
```
314316

315-
Azure CLI command:
317+
1. Create the script file by using the text editor of your choice or by using the following CLI command:
318+
319+
```azurecli
320+
cat <<EOF > script-config.json
321+
{
322+
"fileUris": ["https://raw.githubusercontent.com/Microsoft/dotnet-core-sample-templates/master/dotnet-core-music-linux/scripts/config-music.sh"],
323+
"commandToExecute": "./config-music.sh"
324+
}
325+
EOF
326+
```
327+
328+
1. Run the following command:
316329

317330
```azurecli
318331
az vm extension set \
@@ -324,13 +337,25 @@ az vm extension set \
324337

325338
### Example: Public configuration with no script file
326339

340+
This example uses the following script file named *script-config.json*:
341+
327342
```json
328343
{
329344
"commandToExecute": "apt-get -y update && apt-get install -y apache2"
330345
}
331346
```
332347

333-
Azure CLI command:
348+
1. Create the script file by using the text editor of your choice or by using the following CLI command:
349+
350+
```azurecli
351+
cat <<EOF > script-config.json
352+
{
353+
"commandToExecute": "apt-get -y update && apt-get install -y apache2"
354+
}
355+
EOF
356+
```
357+
358+
1. Run the following command:
334359

335360
```azurecli
336361
az vm extension set \
@@ -342,25 +367,43 @@ az vm extension set \
342367

343368
### Example: Public and protected configuration files
344369

345-
You use a public configuration file to specify the script file's URI. You use a protected configuration file to specify the command to be run.
346-
347-
Public configuration file:
370+
Use a public configuration file to specify the script file's URI:
348371

349372
```json
350373
{
351374
"fileUris": ["https://raw.githubusercontent.com/Microsoft/dotnet-core-sample-templates/master/dotnet-core-music-linux/scripts/config-music.sh"]
352375
}
353376
```
354377

355-
Protected configuration file:
378+
Use a protected configuration file to specify the command to be run:
356379

357380
```json
358381
{
359382
"commandToExecute": "./config-music.sh <param1>"
360383
}
361384
```
362385

363-
Azure CLI command:
386+
1. Create the public configuration file by using the text editor of your choice or by using the following CLI command:
387+
388+
```azurecli
389+
cat <<EOF > script-config.json
390+
{
391+
"fileUris": ["https://raw.githubusercontent.com/Microsoft/dotnet-core-sample-templates/master/dotnet-core-music-linux/scripts/config-music.sh"]
392+
}
393+
EOF
394+
```
395+
396+
1. Create the protected configuration file by using the text editor of your choice or by using the following CLI command:
397+
398+
```azurecli
399+
cat <<EOF > protected-config.json
400+
{
401+
"commandToExecute": "./config-music.sh <param1>"
402+
}
403+
EOF
404+
```
405+
406+
1. Run the following command:
364407

365408
```azurecli
366409
az vm extension set \
@@ -374,7 +417,7 @@ az vm extension set \
374417

375418
## Virtual Machine Scale Sets
376419

377-
If you deploy the Custom Script Extension from the Azure portal, you don't have control over the expiration of the SAS token to access the script in your storage account. The result is that the initial deployment works, but when the storage account's SAS token expires, any subsequent scaling operation fails because the Custom Script Extension can no longer access the storage account.
420+
If you deploy the Custom Script Extension from the Azure portal, you don't have control over the expiration of the SAS token to access the script in your storage account. The initial deployment works, but when the storage account's SAS token expires, any subsequent scaling operation fails because the Custom Script Extension can no longer access the storage account.
378421

379422
We recommend that you use [PowerShell](/powershell/module/az.Compute/Add-azVmssExtension), the [Azure CLI](/cli/azure/vmss/extension), or an [Azure Resource Manager template](/azure/templates/microsoft.compute/virtualmachinescalesets/extensions) when you deploy the Custom Script Extension on a Virtual Machine Scale Set. This way, you can choose to use a managed identity or have direct control of the expiration of the SAS token for accessing the script in your storage account for as long as you need.
380423

0 commit comments

Comments
 (0)