我一直在使用自定义脚本扩展(.ps1)通过Visual Studio部署我的ARM模板,它实际上也是通过VS编译的。但是,我一直试图通过CLI对Azure存储位置上的.ps1文件进行修改来部署它,以便可以由没有VS的其他人部署。但是,每次执行部署时都会失败,该脚本没有.ps1扩展名的错误。通过CLI的Azure ARM模板部署失败.ps1脚本扩展错误
我的ARM模板的自定义脚本扩展部分:
"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--"
}
在CLI部署它失败的结尾:
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的门户网站显示自定义脚本扩展此错误:
[
{
"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."
}
]
我曾尝试:
- “commandToExecute”: “powershell.exe -ExecutionPolicy无限制-NoProfile -nonInteractive - 文件formatDatadisk1.ps1”
- “typeHandlerVersion”: “1.9”
- 重新上传文件到新的存储位置,更改子文件夹路径&访问密钥
- 我的脚本似乎符合; https://docs.microsoft.com/en-us/azure/virtual-machines/windows/extensions-customscript
任何指导意见将非常感激
我在我的实验室测试,我认为根本原因是你应该删除''''命令。 'powershell.exe -ExecutionPolicy Unrestricted -NoProfile -onInteractive -File。/ customscript/formatDatadisk1.ps1' –