I am trying to deploy multiple script to an Azure Windows VM by using Custom Script Extension. The scripts are independent from each other so the order of their deployment doesn't matter. But the scripts are in different in different storage accounts. I have already a working template as below:
{
"properties":{
"mode":"incremental",
"parameters":{
"vmList":{
"value":"[field('name')]"
},
"vmLocation":{
"value":"[field('location')]"
}
},
"template":{
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion":"1.0.0.0",
"parameters":{
"vmList":{
"metadata":{
"description":""
},
"minLength":1,
"type":"String"
},
"vmLocation":{
"metadata":{
"description":""
},
"type":"String"
}
},
"resources":[
{
"apiVersion":"2015-06-15",
"copy":{
"count":"[length(variables('vmListArray'))]",
"name":"myAgent"
},
"location":"[parameters('vmLocation')]",
"name":"[concat(trim(variables('vmListArray')[copyIndex()]),'/myAgent')]",
"properties":{
"autoUpgradeMinorVersion":true,
"protectedSettings":{
"commandToExecute":"[concat ('powershell -ExecutionPolicy Unrestricted -File \"./scripts/installation-myagent.ps1\"')]",
"storageAccountKey":"here comes storage ac. key",
"storageAccountName":"mystorageaccount"
},
"publisher":"Microsoft.Compute",
"settings":{
"fileUris":"[split(variables('fileUris'), ' ')]"
},
"type":"CustomScriptExtension",
"typeHandlerVersion":"1.7"
},
"type":"Microsoft.Compute/virtualMachines/extensions"
}
],
"variables":{
"fileUris":"https://mystorageaccount.blob.core.windows.net/scripts/installation-myagent.ps1",
"vmListArray":"[split(parameters('vmList'),',')]"
}
}
}
}
Because the protected settings of each script is different, i am not sure if this is possible at all. Do you have any idea?