Become root user on Linux servers in Azure

root is the user name or account that by default has access to all commands and files on a Linux or other Unix-like operating system. It is also referred to as the root account, root user and the superuser. The root account is the most privileged on the system and has absolute power over it (i.e., complete access to all files and commands). Among root’s powers are the ability to modify the system in any way desired and to grant and revoke access permissions (i.e., the ability to read, modify and execute specific files and directories) for other users, including any of those that are by default reserved for root.

It is therefore, many times, you need to login as root in order to perform certain administrative actions. Continue reading “Become root user on Linux servers in Azure”

Identify VM’s running status in Azure Resource Manager

Unlike classic model, there is no direct cmdlet to know the status for virtual machine provisioned using resource manager model. We can use the following commands to know the status of a particular virtual machine:

$resourceGroupName = "sharepointvms"
$vmName = "indspstd01"
$vmStatuses = $(Get-AzureRmVM -ResourceGroupName $resourceGroupName -VMName $vmName -Status).Statuses
foreach($vmStatus in $vmStatuses){
 if($vmStatus.Code -ne "ProvisioningState/succeeded")
 {
 Write-Output "$vmName status is `"$($vmStatus.displaystatus)`""
 }
}

Replace the value of …Continue Reading

Enable PowerShell remoting on Azure RM virtual machines

PowerShell remoting is useful to manage virtual machines using PowerShell. When you create a virtual machine in the classic azure model, a winrm endpoint is automatically configured and can be used to manage virtual machines. You’ll just need to import ssl on your local machine and connect to the remoting session. However, same is not created if you create a virtual machine in the resource manager model. So if you try to connect using PowerShell remoting for azure rm vm, you’ll see …Continue Reading

Deleting Azure Virtual Machines

Like other things, there are more than one way to delete Azure Virtual Machines. However with nearly all of them, you have a choice whether you want to delete vhds for the virtual machines or not. Sometimes it may be helpful to retain the disks for later use.

For delete virtual machine from classic portal, use below command:

$name = "mailserver01"
$serviceName = "mailsouthasia"
Remove-AzureVM -Name $name -ServiceName $serviceName

If we need to delete vhds as well, use below …Continue Reading

Using Azure Automation to stop/start virtual machines

Today, we’ll see how we can leverage Azure Automation to stop/start virtual machines in Azure. We’ll begin with how to start virtual machine first and same steps can be applied to stop virtual machines. You’ll only need to change few commands in the runbook associated.

Login into Azure Resource Manager with your credentials. Click on Azure Automation account and then click on the runbooks section highlighted …Continue Reading