Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[CustomScript] extension blocks deployment when using bare command line

See original GitHub issue

I’ve been trying to get this extension to do the simplest thing that could possibly work, which is to run a single command line upon provisioning:

        "settings": {
          "commandToExecute": "sudo apt-get -y update && sudo apt-get -y dist-upgrade"

But whenever I try to do this, my deployments never finish - the extension is created, its provisioning state is set to “running”, but I don’t get any debug output when looking at the properties blade for the extension on the machine it’s provisioned for.

Looking at the code, I believe it is blowing up at:

a) Line 192, where blob_uris is tested for lack of content, even though the documentation states that the fileUrisarray is optional. This because Line 179 would seem to return None in case the setting is missing.

b) Line 278 and following, given that the command line might be mangled by parse_args - which goes against expectations for a Linux sysadmin.

In short, the extension should cover the case of running a bare command line (I would also vastly prefer to be able to inline a full script rather than having to manage access to a storage account, but I’ll file issue #216 for that).

For completion, here’s the relevant resource in the ARM template I’m using:

      "type": "Microsoft.Compute/virtualMachines/extensions",
      "copy": {
        "name": "rancher-master-provisioning-loop",
        "count": "[parameters('masterCount')]"
      "name": "[concat(parameters('virtualMachineNameMaster'), copyIndex(), '/updatePackages')]",
      "apiVersion": "2015-06-15",
      "location": "[resourceGroup().location]",
      "properties": {
        "publisher": "Microsoft.OSTCExtensions",
        "type": "CustomScriptForLinux",
        "typeHandlerVersion": "1.5",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "commandToExecute": "sh sudo apt-get -y update && sudo apt-get -y dist-upgrade"
      "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineNameMaster'), copyIndex())]"

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

ahmetbcommented, Aug 4, 2016

Just to provide input here, @rcarmo is right, the current version of CustomScriptExtension uses shlex.split which splits whoami && whoami into exec(['whoami', '&&', 'whoami']) which is clearly invalid.

In this case this is bug(and also by-design) and fileUris should be used for that.

Easiest workaround is to say "commandToExecute": "sh -c 'whoami && whoami;'" (I realized @rcarmo missed the -c earlier, the failure listed a few comments above happened due to that).

The new version of the Custom Script Extension (which we have not yet published) at always uses sh -c to run the specified comment (like shell=True in Python subprocess), so this issue will be fixed in the short medium term.

rcarmocommented, Aug 4, 2016

@ahmetalpbalkan thanks for that. Saw that repo earlier (I also do Go), hope multi-line scripts as discussed in #216 make their way into the feature set.

Meanwhile, the good news is that I think we can close this as far as the deployment hangup is concerned:

I’ve tested my template with typeHandlerVersion set to 1.0 as @boumenot did in his example, and the deployment worked (with a single whoamicommand, I’m leaving the multi-command stuff to #216, which is where we should probably take the silex.split discussion).

Which means there’s likely to be a bug in the resource provider (or the extension as currently deployed in production) where it regards checking that version number - with 1.5, the deployment never finished, but there were also no error messages or command status sent back to the portal, as reported above.

Thanks for all your help, I’ll keep hammering at the multi-line aspect in #216 because I think that will be a nice improvement for our customers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Custom Script Extension for Windows - Microsoft Learn
The Custom Script Extension downloads and runs scripts on Azure virtual machines (VMs). This extension is useful for post-deployment ...
Read more >
VMware Carbon Black Cloud Sensor Installation Guide
Method 2: Install the Sensor on the Endpoint by using the Command Line or ... Deploy the Carbon Black Cloud Sensor for Windows...
Read more >
Multiple ARM template VM Custom Script Extension post ...
this is what command is required to run the script on the VM. As I said before, this particular deployment block can be...
Read more >
Dell EMC NetWorker Administration Guide
Creating Data Protection Policy resources from a command prompt. 270 ... Non-full backup of Solaris files with modified extended attributes.....863.
Read more >
Virtual Machine Management Guide - Red Hat Customer Portal
You can access a virtual machine's serial console from the command line instead of ... to the virtio-block device, with some additional enhancements....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found