我正在尝试使用我的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
更新:
如果我在脚本中放入Get-AzureRMContext
,它不应该显示我的订阅,就像我从Azure Cloud Shell运行相同命令时显示的那样>>
Account Environment Subscription Tenant
------- ----------- ------------ ------
AzureCloud
我正在尝试使用我的AD凭据从Azure自动化登录到Azure。但是似乎我做错了,在测试时会抛出错误。 $ Cred = Get-AutomationPSCredential -...
看着该错误,我看不到登录名或证书问题。错误出在get-AzureRmResourceGroup
在上下文中找不到预订