将AutomationManagementClient与CertificateCloudCredentials一起使用时出错

时间:2016-05-23 16:17:50

标签: c# azure azure-automation

我试图从MVC应用程序启动azure Runbook。

var cert = new X509Certificate2(Convert.FromBase64String(ConfigurationManager.AppSettings["CertBase64String"]));
var creds = new CertificateCloudCredentials(ConfigurationManager.AppSettings["SubscriptionId"], cert);

AutomationManagementClient automationManagementClient = new AutomationManagementClient(creds);

var content = automationManagementClient.Runbooks.GetAsync(<Resource group name>, ConfigurationManager.AppSettings["AutomationAccount"], <Runbook name>)

我收到此错误:

  

AuthenticationFailed:身份验证失败。授权&#39;标头丢失了。

我从MSDN获得了此代码,但我似乎无法使其正常运行。 (证书是从here下载的证书。)

我尝试在控制台应用中使用TokenCloudCredentials,但似乎工作正常,但我不确定是否可以在MVC应用中使用这些。

我应该如何使用AutomationManagementClient证书凭据?或者如何在网络应用中使用TokenCloudCredentials

1 个答案:

答案 0 :(得分:1)

您尝试使用的Automation SDK使用Azure Resource Manager API,它不支持基于管理证书的身份验证。您需要通过TokenCloudCredentials进行身份验证。显示管理证书支持的文档不正确,我们会尽快更新。