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."
}
]
나는 시도했다 :
- "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 제한 없음 -NoProfile -NonInteractive -File/customscript/formatDatadisk1.ps1' –