01 Run vm show command (Windows/macOS/Linux) using the name of the virtual machine that you want to reconfigure (see Audit section part II to identify the right resource) and the name of the associated resource group as identifier parameters, to obtain the ID of the selected VM:
az vm show
--name cc-project5-web-server
--resource-group cloud-shell-storage-westeurope
--query 'id'
02 The command output should return the requested identifier. The virtual machine ID will be required later, when the role assignment will be created:
"/subscriptions/abcdabcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Compute/virtualMachines/cc-project5-web-server"
03 To be able to log in to your virtual machine using Microsoft Entra ID credentials, you need to install the Microsoft Entra login extension named AADLoginForLinux (Linux) or AADLoginForWindows (Windows). To install the required extension, run vm extension set command (Windows/macOS/Linux) using the name and the associated resource group of the virtual machine that you want to reconfigure as identifier parameters. Replace --publisher and --name parameter values with Microsoft.Azure.ActiveDirectory and AADLoginForWindows if the operating system of your virtual machine is Windows (the command does not produce an output):
az vm extension set
--publisher Microsoft.Azure.ActiveDirectory.LinuxSSH
--name AADLoginForLinux
--vm-name cc-project5-web-server
--resource-group cloud-shell-storage-westeurope
04 Now that the VM extension is installed, you need to configure the Azure Role-Based Access Control (RBAC) policy to determine who can log in to your virtual machine. To create and configure a new role assignment for the user, group or service principal that will access selected VM, run role assignment create command (Windows/macOS/Linux) using one of the following RBAC roles, depending on your needs: Virtual Machine Administrator Login or Virtual Machine User Login. Users assigned with the Virtual Machine Administrator Login role can log in to your virtual machine with administrator privileges and those with the Virtual Machine User Login role can log in to your VM with regular user privileges. As example, the following command request is using the Virtual Machine Administrator Login role. The --assignee parameter value represent the user, group or service principal that you want to assign the role to and the --scope parameter value is the ID of the selected virtual machine, returned at step no. 2:
az role assignment create
--role "Virtual Machine Administrator Login"
--assignee "vm-admin@cloudconformity.onmicrosoft.com"
--scope "/subscriptions/abcdabcd-1234-abcd-1234-abcd1234abcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Compute/virtualMachines/cc-project5-web-server"
05 The command output should return the metadata for the newly created role assignment:
{
"canDelegate": null,
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcd1234abcd/resourcegroups/cloud-shell-storage-westeurope/providers/Microsoft.Compute/virtualMachines/cc-project5-web-server/providers/Microsoft.Authorization/roleAssignments/1234abcd-1234-abcd-1234-abcd1234abcd",
"name": "abcdabcd-1234-abcd-1234-abcd1234abcd",
"principalId": "abcdabcd-1234-1234-1234-abcd1234abcd",
"principalName": "vm-admin@cloudconformity.onmicrosoft.com",
"principalType": "User",
"resourceGroup": "cloud-shell-storage-westeurope",
"roleDefinitionId": "/subscriptions/abcdabcd-1234-abcd-1234-abcd1234abcd/providers/Microsoft.Authorization/roleDefinitions/1234abcd-1234-abcd-1234-abcd1234abcd",
"roleDefinitionName": "Virtual Machine Administrator Login",
"scope": "/subscriptions/abcdabcd-1234-abcd-1234-abcd1234abcd/resourcegroups/cloud-shell-storage-westeurope/providers/Microsoft.Compute/virtualMachines/cc-project5-web-server",
"type": "Microsoft.Authorization/roleAssignments"
}
06 Now you can connect to the selected Azure virtual machine using SSH (Linux) or RDP (Windows) using the User Principal Name (UPN) of your Microsoft Entra ID account.
07 Repeat steps no. 1 – 6 for each Azure virtual machine that you want to reconfigure in order to enable Microsoft Entra ID authentication, deployed in the current subscription.
08 Repeat steps no. 1 – 7 for each subscription available in your Microsoft Azure cloud account.