繁体   English   中英

Azure 自动化 - 使用 AD 用户登录会引发错误

[英]Azure Automation - Login with AD User throws error

我正在尝试使用我的 AD 凭据从 Azure 自动化登录到 Azure。 但是,好像我做错了什么,并且在测试时抛出了错误。

$Cred = Get-AutomationPSCredential -Name 'DefaultAzureCredential'

$null = Add-AzureRmAccount -Credential $Cred -ErrorAction Stop -ErrorVariable err
if($err) {
    throw $err
}

Get-AzureRmResourceGroup -Name "my-resource-group"

错误:

Get-AzureRmResourceGroup : No subscription found in the context.  Please ensure that the credentials you provided are 
authorized to access an Azure subscription, then run Login-AzureRMAccount to login.
At line:8 char:1
+ Get-AzureRmResourceGroup -Name "my-resource-group"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureRmResourceGroup], ApplicationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.GetAzureResourceGroupCommand

更新:

当我从 Azure 自动化脚本运行Get-AzureRm-Context时,它显示我遵循的操作与从Azure Cloud Shell运行相同命令时完全不同。 我应该做不同的事情吗?

Account Environment Subscription Tenant
------- ----------- ------------ ------
        AzureCloud                  

查看错误,我没有看到登录或凭据的问题。 错误出现在get-AzureRmResourceGroup No subscription found in the context 中

当提供的凭据没有订阅时会发生这种情况。 如果您确定帐户已订阅,则问题可能出在 Azure 自动化中加载的模块上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM