Powershell Azure Runbook:要使用什么凭据?

Powershell Azure Runbook:要使用什么凭据?,powershell,azure,credentials,azure-powershell,runbook,Powershell,Azure,Credentials,Azure Powershell,Runbook,我正在尝试创建runbook以重新启动我的web应用程序。我是新手,所以我在自动化刀片中创建了一个凭证,但我不知道用户名/pwd应该是什么?与我的azure登录帐户相同吗? 尝试过了,很明显,当我测试runbook时,会出现以下错误: Add-AzureAccount : unknown_user_type: Unknown User Type At RestartJob:13 char:13 + + CategoryInfo : CloseError: (:) [Add-Az

我正在尝试创建runbook以重新启动我的web应用程序。我是新手,所以我在自动化刀片中创建了一个凭证,但我不知道用户名/pwd应该是什么?与我的azure登录帐户相同吗? 尝试过了,很明显,当我测试runbook时,会出现以下错误:

Add-AzureAccount : unknown_user_type: Unknown User Type
At RestartJob:13 char:13
+ + CategoryInfo          : CloseError: (:) [Add-AzureAccount], 

AadAuthenticationFailedException
   + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount

我也一直在努力在msdn上解决这个问题。。有什么帮助吗?

根据您的描述,我在实验室进行测试。fowwling cmdlet对我有效

$ConnectionAssetName = "shuitest"

# Get the connection
$connection = Get-AutomationConnection -Name $connectionAssetName        

# Authenticate to Azure with certificate
Write-Verbose "Get connection asset: $ConnectionAssetName" -Verbose
$Conn = Get-AutomationConnection -Name $ConnectionAssetName
if ($Conn -eq $null)
{
    throw "Could not retrieve connection asset: $ConnectionAssetName. Assure that this asset exists in the Automation account."
}

$CertificateAssetName = $Conn.CertificateAssetName
Write-Verbose "Getting the certificate: $CertificateAssetName" -Verbose
$AzureCert = Get-AutomationCertificate -Name $CertificateAssetName
if ($AzureCert -eq $null)
{
    throw "Could not retrieve certificate asset: $CertificateAssetName. Assure that this asset exists in the Automation account."
}

Write-Verbose "Authenticating to Azure with certificate." -Verbose
Set-AzureSubscription -SubscriptionName $Conn.SubscriptionName -SubscriptionId $Conn.SubscriptionID -Certificate $AzureCert 
Select-AzureSubscription -SubscriptionId $Conn.SubscriptionID
在执行runbook之前,应该在Azure Portal上创建AssetName和证书

1.Azure Automation中的证书资产

请选择您的运行手册-->
资产
-->证书。

2.创建连接(AssetName)。请选择您的运行手册-->
资产
-->连接。根据您的场景,您应该选择
AzureClasseCertificate


您能提供更多关于脚本的信息吗?您的帐户是什么类型的?Microsoft帐户,如*@hotmail.com@outlook.com?您好,我的脚本非常简单$cred=Get AutomationPSCredential-Name“MyCredential”#Add AzureAccount-Credential$cred Select AzureSubscription-subscription-Name“XXXXMySubscription”Start AzureWebsite-Name“hiyuribot1”起初我想,是的,它应该是我的microsoft帐户,但似乎你应该使用你的广告帐户?我需要自己做一个,还是应该使用目前存在的一个?我有一个上面写着:xxxx.onmicrosoftxxxx.xxx(尝试过但也失败了)好的,你的帐户是Microsoft帐户吗?Microsoft帐户不支持非交互式登录。能否在本地Windows PowerShell上执行脚本?是的,我刚刚完成Runbook测试,它似乎工作正常!非常感谢,从今天早上开始,我一直在搜索MSDN上的教程等,而你今天就省去了:)仅供参考:当我创建新的自动化时,显然它附带了连接和证书,因此我不需要像你建议的那样创建一个新的,只需使用当前的现有版本即可。尽管我仍然有一个问题:当您尝试创建证书时,它需要上传一个证书文件。我该怎么做?嗨,你创建了一个证书。您可以参考此来创建证书。我的证书是用这个链接创建的。是的,的确如此。对不起,我以前没有把它标为答案