簡體   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