1

To run Azure Service Fabric on a cluster I have a vmset. I know the password, but it has to be changed. For a VM I would normally use the "reset password" function on the azure portal, but the vmset does not allow this. Adjusting the password in the resource template is also not allowed.

How to change the password of VM's in a vmset?

rfcdejong
  • 2,219
  • 1
  • 25
  • 51

2 Answers2

7

Update: See the VMSS FAQ:

Change the virtual machine scale set model directly. Available with Compute API 2017-12-01 and later.

Update the admin credentials directly in the scale set model (for example using the Azure Resource Explorer, PowerShell or CLI). Once the scale set is updated, all new VMs have the new credentials. Existing VMs only have the new credentials if they are reimaged.

Alternatively (and for older API versions) you can apply the VM Access extension. The Set-AzureRmVmssOSProfile cmdlet is useful when you're creating a scale set imperatively with PowerShell, but can't be used to change non-modifiable properties of an existing scale set.

Here's an example of using the VM Access extension to modify a scale set:

# Login to your azure account
Login-AzureRmAccount

# Set the scale set and resource group
$vmssName = "myvmss"
$vmssResourceGroup = "myvmssrg"

# Set the username / password
$publicConfig = @{"UserName" = "newuser"}
$privateConfig = @{"Password" = "********"}
 
$extName = "VMAccessAgent"
$publisher = "Microsoft.Compute"

$vmss = Get-AzureRmVmss -ResourceGroupName $vmssResourceGroup -VMScaleSetName $vmssName
$vmss = Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Name $extName -Publisher $publisher -Setting $publicConfig -ProtectedSetting $privateConfig -Type $extName -TypeHandlerVersion "2.0" -AutoUpgradeMinorVersion $true

Update-AzureRmVmss -ResourceGroupName $vmssResourceGroup -Name $vmssName -VirtualMachineScaleSet $vmss
sendmarsh
  • 1,046
  • 7
  • 11
  • @SteelNation need more information than "won't work". What did you try? What version of the Compute API? what was the error? – sendmarsh Apr 05 '18 at 21:21
  • my apologies-- turned out my Compute API version is too old. My scaleset is now stuck in a failed state though, and I can no longer push updated images. – Steel Nation Apr 17 '18 at 21:04
  • is it possible to do the same operation using "az" command line tool? – Devis L. Nov 14 '18 at 04:02
  • Replace "Get-AzureRmVmss" with "Get-AzVmss" and "Add-AzureRmVmssExtension" with "Add-AzVmssExtension", then this technique will work with the current Az module. – hemisphire Nov 22 '21 at 15:29
  • Whoops - and replace "Update-AzureRmVmss" with "Update-AzVmss". – hemisphire Nov 22 '21 at 15:35
0

Looking at the Azure PowerShell commandlets, Set-AzureRmVmssOsProfile makes sense:

PS C:\>Set-AzureRmVmssOSProfile -VirtualMachineScaleSet "ContosoVMSS" -ComputerNamePrefix "Test" -AdminUsername $AdminUsername -AdminPassword $AdminPassword

This command sets operating system profile properties for the virtual machines that belong to the VMSS named ContosoVMSS. The command sets the computer name prefix for all the virtual machine instances in the VMSS to Test and supplies the administrator username and password.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thanks, I will try it out whenever the cluster comes back from 'The cluster i s going through a an upgrade which cannot be interrupted.' which is in for hours.. (including a typo in their error text hehe) – rfcdejong Nov 22 '16 at 16:13