简体   繁体   English

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

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

I am trying to login to Azure from Azure Automation using my AD credential.我正在尝试使用我的 AD 凭据从 Azure 自动化登录到 Azure。 However seems like I am doing something wrong and it's throwing error while testing.但是,好像我做错了什么,并且在测试时抛出了错误。

$Cred = Get-AutomationPSCredential -Name 'DefaultAzureCredential'

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

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

Error:错误:

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

Update:更新:

When I run Get-AzureRm-Context from Azure Automation script it shows me following which is completely different than when I run the same command from Azure Cloud Shell .当我从 Azure 自动化脚本运行Get-AzureRm-Context时,它显示我遵循的操作与从Azure Cloud Shell运行相同命令时完全不同。 Should I do things differently?我应该做不同的事情吗?

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

Looking at the error, i do not see an issue with Login or credential.查看错误,我没有看到登录或凭据的问题。 The error is in the get-AzureRmResourceGroup No subscription found in the context .错误出现在get-AzureRmResourceGroup No subscription found in the context 中

This happens when credential provided does not have a subscription.当提供的凭据没有订阅时会发生这种情况。 If you are sure account has subscription, then the issue might be with the module loaded in Azure Automation.如果您确定帐户已订阅,则问题可能出在 Azure 自动化中加载的模块上。

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

相关问题 在没有用户凭据的情况下登录 Azure 自动化帐户到 Azure AD - Login Azure Automation account, without user credential, to Azure AD 无法使用 Python 自动化创建具有服务原则登录的 Azure AD 用户帐户 - Not able to create Azure AD user account with Service Principle login using Python Automation Azure AD登录没有用户浏览器重定向? - Azure AD Login Without user browser redirect? 当不在域上时,Azure AD RBAC User.IsInRole引发信任关系错误 - Azure AD RBAC User.IsInRole throws Trust Relationship error when not on domain 使用Azure AD创建Azure SQL数据库登录名/用户 - Creating Azure SQL Database login/user using Azure AD 在 SQL 服务器的本地实例上创建用户登录 - 对于 Azure AD 用户 - Create user login on a local instance of SQL Server - for an Azure AD user SQL Azure DB 在 Web 应用程序备份期间抛出错误“用户登录失败” - SQL Azure DB throws error 'login failed for user' during web app backup Windows Azure:用于外部访问的AD应用程序在令牌问题上引发错误 - Windows Azure: AD app for external access throws error on token issue 使用Azure AD自定义登录 - Customize login with azure AD 使用 Azure AD 登录用户 - Login users with Azure AD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM