Azure VM Extension provisioning has taken too long to complete

2.4k Views Asked by At

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
1

There are 1 best solutions below

2
On

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