【发布时间】:2017-09-26 09:28:52
【问题描述】:
我一直在通过带有自定义脚本扩展名 (.ps1) 的 Visual Studio 部署我的 ARM 模板,它实际上也是通过 VS 编译的。但是,我一直在尝试通过 CLI 部署它,并对 Azure 存储位置上的 .ps1 文件进行修改,以便其他没有 VS 的人可以部署它。但是,每次我进行部署时,它都会失败,脚本没有 .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 Unrestricted -NoProfile -NonInteractive -File formatDatadisk1.ps1”
- “typeHandlerVersion”:“1.9”
- 将文件重新上传到新的存储位置,更改子文件夹路径和访问密钥
- 我的脚本似乎符合; https://docs.microsoft.com/en-us/azure/virtual-machines/windows/extensions-customscript
任何指导将不胜感激
【问题讨论】:
标签: json powershell azure templates command-line-interface