I have been deploying my ARM template via Visual Studio with a custom script extension (.ps1) just fine, it was actually compiled via VS too. However, I've been trying to deploy it via CLI with a modification to the .ps1 file being on an Azure Storage Location so it can be deployed by others who don't have VS. However, each time I do a deployment it fails, errors that the script doesn't have a .ps1 extension.
The custom script extension part of my ARM template:
"name": "formatDataDisk",
"type": "extensions",
"location": "[resourceGroup().location]",
"apiVersion": "2016-03-30",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('vmName'))]"
],
"tags": {
"displayName": "formatDataDisk"
},
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.4",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"https://--MYSTORAGEACCOUNTNAME--.blob.core.windows.net/customscript/formatDataDisk.ps1"
],
"commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File './customscript/formatDatadisk1.ps1'"
},
"protectedSettings": {
"storageAccountName": "--MYSTORAGEACCOUNTNAME--",
"storageAccountKey": "--MYSTORAGEKEY--"
}
At the end of the CLI deployment it fails with:
msrest.http_logger : b'{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"Conflict","message":"{\\r\\n \\"status\\": \\"Failed\\",\\r\\n \\"error\\": {\\r\\n \\"code\\": \\"ResourceDeploymentFailure\\",\\r\\n \\"message\\": \\"The resource operation completed with terminal provisioning state \'Failed\'.\\",\\r\\n \\"details\\": [\\r\\n {\\r\\n \\"code\\": \\"VMExtensionProvisioningError\\",\\r\\n \\"message\\": \\"VM has reported a failure when processing extension \'formatDataDisk\'. Error message: \\\\\\"Finished executing command\\\\\\".\\"\\r\\n }\\r\\n ]\\r\\n }\\r\\n}"}]}}'
msrest.exceptions : At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
Deployment failed. {
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "VMExtensionProvisioningError",
"message": "VM has reported a failure when processing extension 'formatDataDisk'. Error message: \"Finished executing command\"."
}
Azure Portal shows this error in the custom script extensions:
[
{
"code": "ComponentStatus/StdOut/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": ""
},
{
"code": "ComponentStatus/StdErr/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded",
"message": "Processing -File ''./customscript/formatDatadisk1.ps1'' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again."
}
]
I have tried:
- "commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File formatDatadisk1.ps1"
- "typeHandlerVersion": "1.9"
- re-uploading the file to a new storage location, changing the subfolder path & the access key
- my script seems to comply with; https://docs.microsoft.com/en-us/azure/virtual-machines/windows/extensions-customscript
Any guidance will be much appreciated