Deploying multiple scripts with CustomScriptExtension on an Azure Windows VM

Viewed 82

I'm trying to deploy multiple PowerShell scripts to an Azure Windows VM by using the CustomScriptExtension.

The scripts are independent from each other so the order of their deployment doesn't matter. Also the scripts are in same blob container.

I have already a working template as below for installing one script at the moment:

$resourceGroup = "myResourceGroup"
$vmName = "myVM"
$location = "easteurope"
$storageAcctName = "myStorageAcct"
$storageKey = $env:ARM_ACCESS_KEY


$fileUri = @("https://xxxxx.blob.core.windows.net/xxxx/01-installTools.ps1")

$protectedSettings = @{"storageAccountName" = $storageAcctName; "storageAccountKey" = $storageKey};

$settings = @{"fileUris" = $fileUri;"commandToExecute" ="powershell -ExecutionPolicy Unrestricted -File 01-installTools.ps1"};


#run command
Set-AzVMExtension -ResourceGroupName $resourceGroup `
    -Location $location `
    -ExtensionName "IIS" `
    -VMName $vmName `
    -Publisher "Microsoft.Compute" `
    -ExtensionType "CustomScriptExtension" `
    -TypeHandlerVersion "1.8" `
    -Settings $settings `
    -ProtectedSettings $protectedSettings;

Also is it possible to use 2 CustomScriptExtensions?

I get a TypeHandlerVersion error if i try to do that.

0 Answers
Related