2017-09-26 5 views
1

Visual Studio를 통해 내 맞춤 스크립트 확장 (.ps1)을 사용하여 ARM 템플릿을 배포했는데 실제로 VS를 통해 컴파일되었습니다. 그러나 Azure 저장소 위치에있는 .ps1 파일을 수정하여 CLI를 통해 배포하려고 했으므로 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\"." 
      } 

푸른 Portal은 사용자 정의 스크립트 확장에이 오류를 보여줍니다

[ 
    { 
     "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." 
    } 
] 

나는 시도했다 :

모든 지침이 훨씬

답변

1

마지막으로, 다른 의견의 도움으로 문제를 해결했습니다. 좀 더 간단한 helloworld.ps1 스크립트로 테스트 해 보니 효과적이었습니다. 분명히 powershell 스크립트에 문제가있었습니다. Visual Studio에서이 스크립트를 만들 때 다음을 맨 위에 배치했습니다.

<# Custom Script for Windows #> 

스크립트의 나머지 부분이 이어집니다. 일단 그것을 제거하고 내 StorageAccount/Container에 다시 업로드하고 ./ commandToExecute에서 삭제했습니다.

의견에 감사드립니다.

+0

제 실험실에서 테스트했는데 근본적인 이유는 명령에서'''를 제거해야한다는 것입니다. 'powershell.exe -ExecutionPolicy 제한 없음 -NoProfile -NonInteractive -File/customscript/formatDatadisk1.ps1' –

0

잘못된 경로를 알 수있을 것이다, 당신은 경로에 컨테이너를 생략해야합니다

"commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File './formatDatadisk1.ps1'" 

는 항상 중첩 된 폴더없이, 같은 디렉토리에 다운로드 한 파일을 넣습니다

"properties": { 
    "publisher": "Microsoft.Compute", 
    "type": "CustomScriptExtension", 
    "typeHandlerVersion": "1.8", 
    "autoUpgradeMinorVersion": true, 
    "settings": { 
     "fileUris": [ 
      "https://backupcicd.blob.core.windows.net/deployment/iis-preConfigureScript.ps1" 
     ], 
     "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File iis-preConfigureScript.ps1" 
    } 
} 
:

여기 나를 위해 작동 정확한 조각이다

+0

슬프게도 이것은 차이가 없었지만, 여전히 같은 오류로 실패합니다. – Beefcake

+0

업데이트 된 답변 확인 – 4c74356b41

+0

나는 아직도 여기서 고민 중이다. 나는 당신의 코드를 설정했으나 여전히 실패했다. 그리고 지금은 버전이 마음에 들지 않는다고 기대하면서 autoUpgradeMinorVersion을 false로 설정했지만, 다시 실패했다. – Beefcake

0

실험실에서 템플릿을 테스트 할 때 동일한 오류 로그가 표시됩니다. ./customscript/을 삭제하면 나에게 적합합니다.

"resources": [ 
    { 
     "name": "[concat(parameters('virtualMachineName'), '/', 'shuitest')]", 
     "type": "Microsoft.Compute/virtualMachines/extensions", 
     "location": "eastus", 
     "apiVersion": "2016-03-30", 
     "dependsOn": [ ], 
     "tags": { 
     "displayName": "shuitest" 
     }, 
     "properties": { 
     "publisher": "Microsoft.Compute", 
     "type": "CustomScriptExtension", 
     "typeHandlerVersion": "1.4", 
     "autoUpgradeMinorVersion": true, 
     "settings": { 
      "fileUris": ["https://shuiwindisks928.blob.core.windows.net/vhds/open_port.ps1"] 

     }, 
     "protectedSettings": { 
      "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File open_port.ps1", 
      "storageAccountName" : "shuiwindisks928", 
      "storageAccountKey" : "jvYg+1aCo+d4b+FI/kdBOtE*******************+kXa0yZR5xrt7a57qgHw==" 
     } 
     } 
    }], 

업데이트 :

는이 link을 참조하시기 바랍니다, VM에 확장 로그를 확인해야합니다.

+0

@Beefcake "commandToExecute"를 사용하는 경우 : "powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File './formatDatadisk1.ps1'"'시도해 볼 수 있습니다. ' '. 나는 그것이 효과가있을 것이라고 확신한다. –

+0

나는. /.없이 전에 시도했지만 작동하지 않았다. 불행히도 저는 스크립트를 배포 할 다른 기회가 없었지만 내일 아침에 또 다른 균열을 줄 것입니다. – Beefcake

+0

@Beefcake Fine, VM 로그인을 확인할 수도 있습니다. https://docs.microsoft.com/en-us/azure/virtual-machines/windows/extensions-customscript#troubleshoot-and-support –