无法通过 Azure 自动化登录到 azure 订阅
Unable to sign in to azure subscription through Azure Automation
我想从订阅 A 执行一本 运行 书,这将在订阅 B 上创建一个存储空间 a/c。我在凭证资产中提供了订阅 B 的 (Username/Password)。
首先,请问是否可以这样做?
当我尝试 运行 下面的代码时,当我 运行 Get-AzureRmSubscription
时出现错误 "Unable to acquire token for tenant 'Common' "
$CredentialAssetName = "login";
$Cred = Get-AutomationPSCredential -Name $CredentialAssetName
if(!$Cred) {
Throw "Could not find an Automation Credential Asset named
'${CredentialAssetName}'. Make sure you have created one in this Automation
Account."
}
add-azurermaccount -credential $Cred
login-AzureRMAccount -Credential $Cred
Select-AzureRmSubscription -SubscriptionName 'Free Trial'
get-azurermsubscription
Unable to acquire token for tenant 'Common'
这只是一个警告,不会影响您的脚本。
please let me know is it possible to do that?
是的,可以,我们可以使用 Azure Runbook 登录订阅 B,然后使用 PowerShell 在该订阅中创建一个 Azure 存储帐户。
Runbook就像PowerShell一样,当我们使用订阅B登录时,脚本将在订阅B上运行。
如果订阅B是微软账号,我们可以按照这个answer登录Azure runbook。 (Microsoft 帐户不 支持非交互式登录。)
我想从订阅 A 执行一本 运行 书,这将在订阅 B 上创建一个存储空间 a/c。我在凭证资产中提供了订阅 B 的 (Username/Password)。
首先,请问是否可以这样做?
当我尝试 运行 下面的代码时,当我 运行 Get-AzureRmSubscription
时出现错误 "Unable to acquire token for tenant 'Common' "$CredentialAssetName = "login";
$Cred = Get-AutomationPSCredential -Name $CredentialAssetName
if(!$Cred) {
Throw "Could not find an Automation Credential Asset named
'${CredentialAssetName}'. Make sure you have created one in this Automation
Account."
}
add-azurermaccount -credential $Cred
login-AzureRMAccount -Credential $Cred
Select-AzureRmSubscription -SubscriptionName 'Free Trial'
get-azurermsubscription
Unable to acquire token for tenant 'Common'
这只是一个警告,不会影响您的脚本。
please let me know is it possible to do that?
是的,可以,我们可以使用 Azure Runbook 登录订阅 B,然后使用 PowerShell 在该订阅中创建一个 Azure 存储帐户。
Runbook就像PowerShell一样,当我们使用订阅B登录时,脚本将在订阅B上运行。
如果订阅B是微软账号,我们可以按照这个answer登录Azure runbook。 (Microsoft 帐户不 支持非交互式登录。)