Azure(和Linux)的新手...CustomScript擴展 - 無法在Azure CentOS VM上運行bash腳本
CentOS 7.2 VM。
我配置一個新的Azure的CentOS的VM,併爲 「自定義腳本用於Linux」 擴展以下: 腳本文件:bob.sh(從本地工作站的選擇) 命令:sh bob.sh
鮑勃.sh:
#!/bin/bash
sudo echo "This is a test" > test.txt
# Update instance packages
sudo yum -y check-update
# Download and install Node.js
sudo yum install -y epel-release
sudo yum install -y nodejs npm --enablerepo=epel
VM部署完成後,儀表板上出現「部署失敗」錯誤。
錯誤/狀態消息,因爲Azure的認爲我是一臺電腦,在JSON顯示給我的是:
{
"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 'CustomScriptForLinux'. Error message: \"Malformed status file (000003)Invalid status/status: failed\"."
}
]
}
}
畸形狀態文件(000003)無效的狀態/狀態:失敗?
DuckDuckGo先生似乎沒有關於此錯誤的信息。
我SSH到VM:
文件test.txt不存在。
我試圖在虛擬機上查看/var/log/azure/custom-script/handler.log上的日誌文件,但我沒有權限。
我可以成功地手動運行腳本中的每一步。
有什麼建議嗎?
UPDATE:
waagent.log(最後30行)
2017/03/15 18:59:08.306400 INFO Agent WALinuxAgent-2.2.5 error state: Last Failure: 0.0, Total Failures: 0, Fatal: False
2017/03/15 18:59:08.318722 INFO Ensuring Agent WALinuxAgent-2.2.5 is downloaded
2017/03/15 18:59:08.326959 INFO Agent WALinuxAgent-2.2.5 was previously downloaded - skipping download
2017/03/15 18:59:08.337453 INFO Agent WALinuxAgent-2.2.5 loaded manifest from /var/lib/waagent/WALinuxAgent-2.2.5/HandlerManifest.json
2017/03/15 18:59:08.351363 INFO Wire server endpoint:168.63.129.16
2017/03/15 18:59:08.392832 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Expected handler state: enabled
2017/03/15 18:59:08.405362 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Current handler state is: NotInstalled
2017/03/15 18:59:08.418354 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Download extension package
2017/03/15 18:59:08.451541 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Unpack extension package
2017/03/15 18:59:08.484619 INFO Event: name=Microsoft.OSTCExtensions.CustomScriptForLinux, op=Download, message=Download succeeded
2017/03/15 18:59:08.505998 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Initialize extension directory
2017/03/15 18:59:08.522399 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Update settings file: 0.settings
2017/03/15 18:59:08.538153 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Install extension.
2017/03/15 18:59:08.553039 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Launch command:customscript.py -install
2017/03/15 18:59:08 CustomScriptForLinux started to handle.
2017/03/15 18:59:08 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] cwd is /var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1
2017/03/15 18:59:08 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Change log file to /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.5.2.1/extension.log
2017/03/15 18:59:09.573891 INFO Event: name=Microsoft.OSTCExtensions.CustomScriptForLinux, op=Install, message=Launch command succeeded: customscript.py -install
2017/03/15 18:59:09.591446 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Enable extension.
2017/03/15 18:59:09.602945 INFO [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Launch command:customscript.py -enable
2017/03/15 18:59:09 CustomScriptForLinux started to handle.
2017/03/15 18:59:09 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] cwd is /var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1
2017/03/15 18:59:09 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Change log file to /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.5.2.1/extension.log
2017/03/15 18:59:09 CustomScriptForLinux started to handle.
2017/03/15 18:59:09 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] cwd is /var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1
2017/03/15 18:59:09 [Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.1] Change log file to /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.5.2.1/extension.log
2017/03/15 18:59:10.628480 INFO Event: name=Microsoft.OSTCExtensions.CustomScriptForLinux, op=Enable, message=Launch command succeeded: customscript.py -enable
2017/03/15 18:59:10.815782 INFO Event: name=WALinuxAgent, op=HealthCheck, message=Blob type match [PageBlob]
2017/03/15 19:14:05.254971 INFO Agent WALinuxAgent-2.2.5 launched with command 'python -u bin/WALinuxAgent-2.2.5-py2.7.egg -run-exthandlers' is successfully running
2017/03/15 19:14:05.273919 INFO Event: name=WALinuxAgent, op=Enable, message=Agent WALinuxAgent-2.2.5 launched with command 'python -u bin/WALinuxAgent-2.2.5-py2.7.egg -run-exthandlers' is successfully running
handler.log:
No such file or directory
'sudo su; cat /var/log/waagent.log; cat/var/log/azure/custom-script/handler.log'並在此處發帖 – 4c74356b41
從本地工作站選擇的是什麼意思?您希望該文件可以在您配置的VM上神奇地可用?它不會,你必須首先將它下載到虛擬機 – 4c74356b41
是的,我期望這個文件能夠神奇地可用,因爲我來自AWS背景,即UserData。使用Azure Blob存儲中的數據/文件自動進行自動配置而無需手動將文件推送到現有虛擬機的最佳做法是什麼? – programmerj