31.0k views
4 votes
Grant VM access to an Azure resource and obtain access token from Azure Resource Manager.

A) Use Azure PowerShell, grant access, obtain token
B) Use Azure CLI, obtain token, grant access
C) Access Azure Portal, grant access, obtain token
D) Use Azure SDK, obtain token, grant access

User Avalon
by
8.6k points

1 Answer

3 votes

Final answer:

The correct answer is A) Use Azure PowerShell, grant access, obtain token.

Step-by-step explanation:

The correct answer is A) Use Azure PowerShell, grant access, obtain token. Azure PowerShell is a command-line tool that allows you to manage and automate Azure resources. By using Azure PowerShell, you can grant VM access to an Azure resource and obtain an access token from Azure Resource Manager. Here's an example of the PowerShell commands you could use:

  1. Connect-AzAccount
  2. Set-AzContext -SubscriptionId <subscription_id>
  3. $vm = Get-AzVM -ResourceGroupName <resource_group_name> -Name <vm_name>
  4. New-AzRoleAssignment -ObjectId <objectId_of_user> -RoleDefinitionName 'Contributor' -Scope $vm.Id
  5. $token = (Get-AzAccessToken).Token
User Ahmed Aboud
by
8.7k points