2

As the title, I deleted VMAccessForLinux Extension. However, there's no way to get back the extension.

How to re-install the extension on my VM?

In the case of using Azure CLI, it get me error like the follow:


Wed Feb 24 2016 20:56:17 GMT+0900 (KST): { [Error: Invalid update to extension reference for role: Look360VM and reference: VMAccessForLinux.] code: 'BadRequest', statusCode: 400, requestId: '36d5f8a1bcd37ce480e26e31a2742249' } Error: Invalid update to extension reference for role: Look360VM and reference: VMAccessForLinux. at Function.ServiceClient._normalizeError (/usr/local/azure/node_modules/azure-common/lib/services/serviceclient.js:815:23) at /usr/local/azure/node_modules/azure-common/lib/services/filters/errorhandlingfilter.js:44:29 at Request._callback (/usr/local/azure/node_modules/azure-common/lib/http/request-pipeline.js:109:14) at Request.self.callback (/usr/local/azure/node_modules/azure-common/node_modules/request/request.js:199:22) at Request.emit (events.js:110:17) at Request. (/usr/local/azure/node_modules/azure-common/node_modules/request/request.js:1160:14) at Request.emit (events.js:129:20) at IncomingMessage. (/usr/local/azure/node_modules/azure-common/node_modules/request/request.js:1111:12) at IncomingMessage.emit (events.js:129:20) at _stream_readable.js:908:16


It says 'BadRequest'. I don't know why exactly, but it might be I deleted the extension.

Please comment on the solution if you experienced. Thanks.

Kabkee
  • 198
  • 2
  • 11

3 Answers3

2

In the current Azure CLI, always use the utility command azure vm reset-access and its parameters to perform this work, assuming you're on ARM deployment. It's simply the easiest way to do this, since you do not have to worry about json stuff....

azure vm reset-access --help
help:    Enables you to reset Remote Desktop Access or SSH settings on a Virtual Machine and to reset the password for the account that has administrator or sudo authority.
help:
help:    Usage: vm reset-access [options] <resource-group> <name>
help:
help:    Options:
help:      -h, --help                             output usage information
help:      -v, --verbose                          use verbose output
help:      -vv                                    more verbose with debug output
help:      --json                                 use json output
help:      -g, --resource-group <resource-group>  the resource group name
help:      -n, --name <name>                      the virtual machine name
help:      -u, --user-name <user-name>            the user name
help:      -p, --password <password>              the password
help:      -M, --ssh-key-file <ssh-key-file>      path to public key PEM file or SSH Public key file for SSH authentication (valid only when os-type is "Linux")
help:      -r, --reset-ssh                        Reset the SSH configuration to default
help:      -E, --extension-version <version>      Version of VM Access extension [1.4]
help:      -e, --expiration <expiration>          password expiration
help:      -R, --remove-user <remove-user-name>   Remove a user account with specified name
help:      -s, --subscription <subscription>      the subscription identifier
help:
help:    Current Mode: arm (Azure Resource Management)
squillace
  • 41
  • 1
  • Don't know why azure don't list this as a solution ,easy and straightforward, thanks! – SeanJ Apr 24 '16 at 00:51
  • This topic does: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-using-vmaccess-extension/ – squillace Apr 29 '16 at 06:06
1

I get the exact error as you did when using Azure CLI to install the extension to my VM. I haven't identify the root cause yet. But, I have an alternative way to install the extension, using Azure PowerShell instead.

Here is the command:

$vm = Get-AzureVm -ServiceName <your cloud service> -Name <your vm>

Set-AzureVMExtension -ExtensionName "VMAccessForLinux" -VM $vm `
    -Publisher "Microsoft.OSTCExtensions" -Version "1.*" | Update-AzureVM




After a few diggings, I have found the root cause. You need to specify the "Reference Name" for "VMAccessForLinux", which is "Microsoft.OSTCExtensions.VMAccessForLinux". For azure vm extension set, by default, it use the name of extension as the reference name, which works for most of the extensions. However, "VMAccessForLinux" is not the case.

Here is the command:

azure vm extension set "<your VM>" "VMAccessForLinux" "Microsoft.OSTCExtensions" "1.*" -r "Microsoft.OSTCExtensions.VMAccessForLinux"
Jack Zeng
  • 2,257
  • 12
  • 23
  • Still getting this: C:\tmp>azure vm extension set "MostM" "VMAccessForLinux" "Microsoft.OSTCExtensions" "1.*" -r "Microsoft.OSTCExtensions.VMAccessForLinux" info: Executing command vm extension set VM Extension version: 1.5 + Looking up the VM "VMAccessForLinux" error: Virtual machine "VMAccessForLinux" not found under the resource group "MostM" info: Error information has been recorded to C:\Users\xxx\.azure\azure.err error: vm extension set command failed – SeanJ Apr 24 '16 at 00:03
1

Posting answer to enable for a new Resource manager VMs:

$RGName = "<Rg name>"
$VmName = "<Vm name>"
$Location = '<VM Location>'

$ExtensionName = 'VMAccessForLinux'
$Publisher = 'Microsoft.OSTCExtensions'
$Version = '1.4'

$PublicConf = '{}'
$PrivateConf = '{
  "username": "<new username>",
  "password": "<new password>",
  "reset_ssh": true
}'

Set-AzureRmVMExtension -ResourceGroupName $RGName -VMName $VmName -Location $Location -Name $ExtensionName -Publisher $Publisher -ExtensionType $ExtensionName -TypeHandlerVersion $Version -Settingstring $PublicConf -ProtectedSettingString $PrivateConf

See https://github.com/Azure/azure-linux-extensions/tree/master/VMAccess for more details.

Arpit Jain
  • 782
  • 1
  • 6
  • 12