[英]Connect-AzAccount Powershell on-prem
I am new to Azure and I've successfully installed PowerShell on my macOS.我是 Azure 的新手,并且已在我的 macOS 上成功安装了 PowerShell。 Now I want to run get-azvm command and stop/delete a vm from on-prem (not cloud shell).
现在我想运行 get-azvm 命令并从本地(不是云外壳)停止/删除虚拟机。
First thing I did from Terminal: 1. PWSH to launch PowerShell 2. Connect-AzAccount, browser opens to authenticate and I get an error:我从终端做的第一件事: 1. PWSH 启动 PowerShell 2. Connect-AzAccount,浏览器打开进行身份验证,我收到一个错误:
Connect-AzAccount xx: Device authentication is required. Connect-AzAccount xx:需要设备身份验证。 Trace ID: xx Correlation ID: xx + CategoryInfo : CloseError: (:) [Connect-AzAccount], AadAuthenticationFailedException
跟踪 ID:xx 相关 ID:xx + CategoryInfo:CloseError:(:) [Connect-AzAccount],AadAuthenticationFailedException
{ } { }
Please, what am I doing wrong?请问,我做错了什么? Do I need to register my on-prem machine somewhere?
我需要在某处注册我的本地机器吗?
Thanks for the help.谢谢您的帮助。
As mentioned in above comment - you might have conditional access policies enabled on your Azure AD so you might want to check it out and confirm.正如上面的评论中提到的 - 您可能在 Azure AD 上启用了条件访问策略,因此您可能需要检查并确认。 Secondly, if that's not the case - try running commands below before you access your azure resources
其次,如果情况并非如此 - 请在访问 azure 资源之前尝试运行以下命令
Add-AzAccount
Get-AzSubscription -SubscriptionId "your_azure_subscription_id" | Select-AzSubscription
$vm = Get-AzVM -ResourceGroupName "your_vm_resource_group_name" -Name "your_vm_name"
Hope it helps?希望能帮助到你?
According to the error from Connect-AzAccount
, Looks your account is MFA-enabled , please use the authentication methods to authenticate.根据
Connect-AzAccount
的错误,看来您的帐户已启用 MFA ,请使用身份验证方法进行身份验证。 Or you can create a service principal, assign a role for it in the subscription , then you can login with the service principal and use it to Get-AzVM
, details here .或者您可以创建一个服务主体, 在订阅中为其分配一个角色,然后您可以使用该服务主体登录并使用它来
Get-AzVM
,详细信息请参见此处。
I continue with az login command.
我继续使用 az login 命令。 Result: You have logged in. Now let us find all the subscriptions to which you have access..
结果:您已登录。现在让我们找到您有权访问的所有订阅。
You should note, Connect-AzAccount
is used to login the Azure Powershell , az login
is used to login the Azure CLI , they are different.请注意,
Connect-AzAccount
用于登录Azure Powershell , az login
用于登录Azure CLI ,它们是不同的。 From the output, looks you logged in successfully in Azure CLI, you could use az account set --subscription <subscription-id>
to set the subscription which you want to get the VMs from, then use az vm list
to list VMs.从输出来看,您在 Azure CLI 中成功登录,您可以使用
az account set --subscription <subscription-id>
设置要从中获取 VM 的订阅,然后使用az vm list
列出 VM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.