0

When i am trying to deploy a template with extension i am getting timed out error as "Provisioning of VM extension InstallLamp has timed out. Extension provisioning has taken too long to complete. The extension did not report a message"

I am trying to install MySql through extension in a VM.

here is the extension code

{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2018-06-01",
"name": "[concat(variables('vmName'),'/', 'InstallMySQL')]",
"location": "[parameters('location')]",
"dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/',variables('vmName'))]"
],
"properties": {
    "publisher": "Microsoft.Compute",
    "type": "CustomScriptExtension",
    "typeHandlerVersion": "1.7",
    "autoUpgradeMinorVersion":true,
    "settings": {
        "fileUris": [
            "<url of custom script>"
        ],
        "commandToExecute": "sampleScript.sh"
    }
}

Here is the sampleScript.sh code

sudo apt-get -y update
dbpass=12345678
export DEBIAN_FRONTEND=noninteractive
echo "mysql-server-5.7 mysql-server/root_password password" $dbpass | sudo debconf-set-selections >>
echo "mysql-server-5.7 mysql-server/root_password_again password" $dbpass | sudo debconf-set-selections
sudo apt-get -y install mysql-server-5.7
sudo apt-get -y install apache2 php7
sudo service apache2 restart
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
Asif TMd
  • 9
  • 3

1 Answers1

0

For this issue, the mistake you made is that the commands in the script are still interactive because of the command sudo. When you use the command sudo, it will need you to input the password of the root user.

And as I know, the VM extension already has the root permission to install the software. So you do not need to use the command sudo in your script. You just need to be sure the script is available and change it like this:

apt-get -y update
dbpass=12345678
export DEBIAN_FRONTEND=noninteractive
echo "mysql-server-5.7 mysql-server/root_password password" $dbpass | debconf-set-selections
echo "mysql-server-5.7 mysql-server/root_password_again password" $dbpass | debconf-set-selections
apt-get -y install mysql-server-5.7
apt-get -y install apache2 php7
service apache2 restart
Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Hi Charles, firstly thanks for your time. i have sorted out the error just couple of hours back. script is fine with sudo and in json template at the extension resource I changed ** "publisher": "Microsoft.Compute" ** to ** "publisher": "Microsoft.Azure.Extensions" ** – Asif TMd Feb 19 '20 at 11:52
  • @AsifTMd Any more questions? Do you solve the problem? Please let me know it. – Charles Xu Feb 28 '20 at 05:52