Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, June 2, 2016 3:01 PM
I am using the following page as a guide on how to deploy Custom Script Extension using ARM templates:
The script that I want to execute using Custom Script Extension has parameters that need to be passed to it. For e.g.:
param(
$variable1
)
Write-Host "Successfully passed $variable1 to the script executed through CSE!"
How do I pass parameters (e.g. $variable1) to the script to execute using Custom Script Extension through ARM templates?
All replies (11)
Tuesday, June 7, 2016 11:44 AM âś…Answered | 1 vote
Hello Charlie,
Thank you for waiting for a reply from us and apologies for the delay in getting back to you.
I was checking with a specialist, Daichi Isami who has given his scripts for you:
https://github.com/normalian/eclipse-script-windows-vm/blob/master/azuredeploy.json
https://github.com/normalian/eclipse-script-windows-vm/blob/master/Eclipse-JDK-Setup-Script.ps1
Please let me know if this was helpful to you.
Regards,
Sapna Girish
Sapna G
Friday, June 3, 2016 12:57 PM
Hello Charlie,
Greetings from Microsoft Azure.
In order to pass parameters to the script to change its actions, please follow the below article:
http://www.powershellmagazine.com/2014/04/30/understanding-azure-custom-script-extension/
I hope this helps you !!!
Regards,
Sapna Girish
Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Sapna G
Friday, June 3, 2016 5:56 PM
Hello Sapna,
Your linked article does not help me. That article explains how to pass parameters to Custom Script Extension using PowerShell cmdlets. I am interested in how to pass parameters to Custom Script Extension when deploying an ARM (JSON) template.
Friday, June 3, 2016 6:58 PM
Hello Charlie,
Thanks for getting back to us and apologies for a not appropriate reply.
I hope the below link helps you because this what I found related to your query:
https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/
Regards,
Sapna Girish
Sapna G
Saturday, June 4, 2016 4:56 AM
Hello Sapna,
I appreciate your help, but the link that you posted is again not useful. That link talks about passing parameters in general to an ARM template, but does not mention how to pass parameters specifically to the script to be executed using Custom Script Extension.
Sunday, June 5, 2016 8:20 PM
Bump for visibility. Answer still pending.
Monday, June 6, 2016 2:28 PM
Bump. Answer still pending.
Wednesday, June 8, 2016 2:55 PM
So you're saying that the actual definition of Custom Script Extension in the ARM template would look like something this:
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'),'/CustomScriptExtension')]",
"apiVersion": "2015-05-01-preview",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.7",
"autoUpgradeMinorVersion":true,
"settings": {
"fileUris": [ "[parameters('scriptFile')]" ],
"commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -file ', Eclipse-JDK-Setup-Script.ps1, ' ', http://mirrors.neusoft.edu.cn/eclipse/technology/epp/downloads/release/mars/2/eclipse-jee-mars-2-win32-x86_64.zip, ' ', http://azure.azulsystems.com/zulu/zulu8.13.0.5-jdk8.0.72-win_x64.zip, ' ', adminUserName)]"
}
}
I have not hadsuccess when the "commandToExecute" line is defined like this:
commandToExecute = "powershell -File Add-To-Domain-No-PW.ps1 $DomainUserName $DomainPassword"
What am I missing?
Wednesday, June 8, 2016 8:56 PM
Follow-up: my CSE declaration looks like this:
"properties": {
"typeHandlerVersion": "1.3",
"publisher": "Microsoft.Compute",
"settings": {
"fileUris": [
"https://<storageaccount>.blob.core.windows.net/<containername>/Add-To-Domain-No-PW.ps1"
],
"commandToExecute": "powershell -File Add-To-Domain-No-PW.ps1 -svcAcctUserName <servicveaccountgoeshere> svcacctcldad -secpasswd <passwordgoeshere>"
},
"type": "CustomScriptExtension",
"autoUpgradeMinorVersion": "true",
"protectedSettings": {
"storageAccountName": "<storageacccount>",
"storageAccountKey": "<storagekey>"
}
},
"type": "Microsoft.Compute/virtualMachines/extensions",
"copy": {
"count": "[parameters('numberOfInstances')]",
"name": "extension2loop"
},
"apiVersion": "2015-06-15",
"location": "southcentralus"
}
The only difference that I see is that the value of "commandToExecute" is not wrapped around square brackets. Will give that a try.
Wednesday, June 8, 2016 11:00 PM | 1 vote
Alright, I had a weird bug in the script I was executing through CSE. Marking Sapna's post as an answer to close this thread.
Thursday, June 9, 2016 12:34 PM
Hello Charlie,
Thanks for getting back to us and confirming that the issue is resolved.
Regards,
Sapna Girish
Sapna G