简体   繁体   中英

How to install the Azure linux agent (waagent) via CLI on a VM

I am creating a VM from a disk. But, I am unable to give the credentials to this VM such as Username and Password.

az vm create --resource-group RESOURCE-GRP-NAME --location eastus --name VM-NAME --os-type linux --attach-os-disk DISK-NAME

When the VM gets created it says, VM agent Unavailable and I am unable to ssh to the VM.

As VM Agent is required for the VM to get connected via ssh, how to install this VM Agent via CLI on VM in azure.

Please help me with some comands.

Not exactly the answer you are looking for, but you can provide User and Password if you deploy the VM using "az group deployment create [PARAMS]". As an param you give a deployment file containing the resources you want do deploy. In this specification you can provide user and password for a VM.

For an example of such files: log in in the web front end of azure and open the resource group there is an "Automation Script" tab. Download this description.

There is an part in the VM Resource description like

            "osProfile": {
            "computerName": "[parameters('virtualMachines_int02_apl01_name')]",
            "adminUsername": "root01",
            "linuxConfiguration": {
                "disablePasswordAuthentication": false
            },

this also allows you to say "adminPassword": XYZ

The other question:

There is an CLI part "az vm run-command" which might to do what you want... or look this example: Stackoverflow ticket

The reason you are not passing credentials is because you are creating from an existing disk. Hence, this disk already had credentials setup. So there should be no need to reconfigured them.

If you forgot the credentials, then you can reset them via the Azure Portal. However, as you mentioned this does required the waagent to be installed and functioning. In order to install the agent you will need to actually SSH into your VM.

You can follow this process to manually reset the password of your VM: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/reset-password

Then, once you are able to SSH you can manually install the waagent by following this: http://blog.admindiary.com/install-microsoft-azure-linux-agent-waagent/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM