如何登录到 Azure 服务主体 [英] How to log in to Azure service principal

本文介绍了如何登录到 Azure 服务主体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. Connect-AzureRMAccount 不起作用.我不在乎.我不想通过需要博士学位的过程来理解为什么 PowerShell 永远不想工作.所以我将使用 Login-AzureRMAccount

  2. 我遵循了文档.当然这是不够的,所以我在这里.

    有关详细信息,请参阅此类似问题.

    1. Connect-AzureRMAccount doesn't work. I don't care. I don't want to run through the process of needing a PhD to understand why PowerShell never wants to work. So I'm going to use Login-AzureRMAccount

    2. I've followed the docs. Of course it's inadequate so here I am. https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azurermps-6.6.0

    "In order to get the service principal's credentials as the appropriate object, use the Get-Credential cmdlet. This cmdlet will display a dialog box to enter the service principal user ID and password into."

    Where do I even find my userID? I followed another docs instructions on creating an SP and all I did was create an app. I got the SP object in PowerShell, all it did was give me a NAME of the SP .

    Now that I understand what User ID is. HOW do I log in? I use Login-AzureRmAccount AND Add-AzureRMAccount and they BOTH say

    $p = Get-Credential
    Add-AzureRmAccount -ServicePrincipal -ApplicationId "XXXXXXXXXX" -Credential $p -TenantId "XXXXXXXXXXX"
    Add(/Login)-AzureRmAccount : Parameter set cannot be resolved using the specified named parameters.
    

    解决方案

    Try the command below to log in as a service principal,it works fine on my side.

    $azureAplicationId ="Azure AD Application Id"
    $azureTenantId= "Your Tenant Id"
    $azurePassword = ConvertTo-SecureString "strong password" -AsPlainText -Force
    $psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $azurePassword)
    Add-AzureRmAccount -Credential $psCred -TenantId $azureTenantId  -ServicePrincipal 
    

    For more details, refer to this similar issue.

    这篇关于如何登录到 Azure 服务主体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆