Is it possible to Running scripts from a local share inside arm template as it possible via powershell.
$protectedSettings = @{"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File \\filesvr\build\serverUpdate1.ps1"};
Set-AzVMExtension -ResourceGroupName <resourceGroupName> `
-Location <locationName> `
-VMName <vmName> `
-Name "serverUpdate"
-Publisher "Microsoft.Compute" `
-ExtensionType "CustomScriptExtension" `
-TypeHandlerVersion "1.10" `
-ProtectedSettings $protectedSettings
arm:
{
"fileUris": ["https://mystorage.blob.core.windows.net/privatecontainer/script1.ps1"],
"commandToExecute": "powershell.exe script1.ps1",
"managedIdentity" : {}
}
Thanks
CodePudding user response:
Is it possible to Running scripts from a local share inside arm template as it possible via powershell.
Yes ,It is possible we can use the PowerShell scripts with ARM template.
Likewise ,you can check the below sample :
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.8",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"https://mystorage.blob.core.windows.net/deployment/iis-preConfigureScript.ps1"
],
"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File iis-preConfigureScript.ps1"
}
}
- Need to make sure that we have saved the correct
PowerShell script
in our desired path and passing thecorrect url
in settings.
For more information please refer the below links:-
SO THREAD|Azure ARM template deployment via CLI failing with .ps1 script extension error
MICROSOFT DOCUMENT| Use deployment scripts in ARM templates.