4

I am trying to deploy in Azure Vm Scale Set using Run Custom Script VM extension on VM scale set in Azure DevOps Release Pipleine. I've a shell script which executes post deployment tasks.

In release pipeline I am using a storage account to archive artifacts and also unchecked the Skip Archiving custom scripts. In VMSS deployment task I am getting the following error:

2020-03-06T22:59:44.7864691Z ##[error]Failed to install VM custom script extension on VMSS. 
Error: VM has reported a failure when processing extension 'AzureVmssDeploymentTask'. 
Error message: "Enable failed: failed to execute command: command terminated with exit status=126

[stdout]

extracting archive cs.tar.gz
Invoking command: ./"main.sh"

[stderr]

./customScriptInvoker.sh: line 12: ./main.sh: Permission denied

I found the customScriptInvoker.sh under /var/lib/waagent/custom-script/download/1 directory in scale set vm

#!/bin/bash
if [ -n "$1" ]; then
   mkdir a
   echo "extracting archive $1"
   tar -xzC ./a -f $1
   cd ./a
fi

command=$2" "$3
echo $command
echo "Invoking command: "$command

eval $command

What should be the way around of this issue?

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
Ratul
  • 453
  • 7
  • 15

2 Answers2

2

it seems like a shell execute permission is missing

I am assuming you are running the bash script from the same folder I would try

chmod +rx main.sh

you can verify permissions

ls -l main.sh
Anass Kartit
  • 2,017
  • 15
  • 22
0

Can you also post the ownership of the main.sh and customScriptInvoker.sh using

ls -la main.sh
ls -la customScriptInvoker.sh

Check if they are owned by different accounts that may not be in the same group. If that is the case, you would also get a permission denied error when trying to execute the main.sh script from inside other script. If that is the case, you can use the chgrp command to change the main.sh file to be owned by the same group as the other file. You can also use chown to change the ownership of the main.sh file to be have the same ownership as the other file. Its hard to tell without seeing the permissions and ownership of the files.

Joseph Ishak
  • 1,194
  • 1
  • 9
  • 18