1

New to Azure (and Linux)...

CentOS 7.2 VM.

I configure a new Azure CentOS VM, and set the following for "Custom Script for Linux" extension: Script files: bob.sh (Selected from local workstation) Command: sh bob.sh

bob.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

After VM deploys, I get a "Deployment Failed" error on the dashboard.

The error/status message, displayed to me in JSON because Azure thinks I am a computer, is:

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

Malformed status file (000003)Invalid status/status: failed??

Mr. DuckDuckGo seems to have no information on this error.

I SSH into the VM:

File test.txt does not exist.

I attempted to view log files on the VM at /var/log/azure/custom-script/handler.log, but I don't have permission.

I can manually run each step in the script successfully.

Any suggestions?

UPDATE:

waagent.log (Last 30 lines)

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
4
  • sudo su; cat /var/log/waagent.log; cat /var/log/azure/custom-script/handler.log and post it here Commented Mar 15, 2017 at 19:23
  • what does selected from local workstation mean? You expect that file to be magically available on the VM you provisioned? It won't be, you have to download it to the VM first Commented Mar 15, 2017 at 19:29
  • Yeah, I expected the file to be magically available since I am coming from an AWS background i.e. UserData. What is the best course of action for having a VM automatically self-provision using data/files from Azure Blob storage without having to manually push a file to an existing VM. Commented Mar 15, 2017 at 19:32
  • 1
    @programmerj You had better check log /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.5.2.1/extension.log Commented Mar 16, 2017 at 2:00

2 Answers 2

2

According to your description, I use your script and test in my lab. I get same error log. I check log in /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux‌​/1.5.2.1/extension.l‌​og. I find some sudo error.

Please remove sudo in your script. Azure executes the script as root user. After remove sudo, you could install extension successfuly.

#!/bin/bash
echo "This is a test" > test.txt

# Update instance packages
yum -y check-update

# Download and install Node.js
yum install -y epel-release
yum install -y nodejs npm --enablerepo=epel
Sign up to request clarification or add additional context in comments.

1 Comment

Not sure why you were downvoted; this is the correct answer. I removed "sudo" from all of my script entries and now it works. Thanks for your help!!
0

For the file to be available on the VM, just upload it somewhere publicly available and issue a command to download it. See this example

{
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(variables('vmName'),'/', variables('extensionName'))]",
  "apiVersion": "[variables('apiVersion')]",
  "location": "[resourceGroup().location]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
  ],
  "properties": {
    "publisher": "Microsoft.Azure.Extensions",
    "type": "CustomScript",
    "typeHandlerVersion": "2.0",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "fileUris": "[split(parameters('fileUris'), ' ')]", ## << file url goes here
      "commandToExecute": "[parameters('commandToExecute')]"
    },
    "protectedSettings": { ## << these are needed if you are using Azure Blob which is not publicly accessible
      "storageAccountName": "[parameters('customScriptStorageAccountName')]",
      "storageAccountKey": "[parameters('customScriptStorageAccountKey')]"
    }
  }
}

4 Comments

A script can just be uploaded from your workstation to the portal, the script will then be executed when the VM is provisioned. See azure.microsoft.com/en-us/blog/… section: Deploy the CustomScript Extension through Azure Portal
Yeah...its the second step. I just first want to ensure I can get a VM to pull down and successfully execute a script.
you cant automate portal actions, obviously, my answer deals with that
correct, i understand that. thanks for you answer, i will certainly use it as a reference when i begin researching automation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.