gpt4 book ai didi

c# - 将 AutomationManagementClient 与 CertificateCloudCredentials 结合使用时出错

转载 作者:太空宇宙 更新时间:2023-11-03 12:45:43 24 4
gpt4 key购买 nike

我正在尝试从 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: Authentication failed. The 'Authorization' header is missing.

我从 MSDN 获得此代码但我似乎无法让它发挥作用。(证书是从 here 下载的证书)。

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

有什么想法应该如何将 AutomationManagementClient 与证书凭据一起使用?或者如何在网络应用中使用TokenCloudCredentials

最佳答案

您尝试使用的自动化 SDK 使用 Azure 资源管理器 API,该 API 不支持基于管理证书的身份验证。您需要通过 TokenCloudCredentials 进行身份验证。显示管理证书支持的文档不正确,我们将尽快更新。

关于c# - 将 AutomationManagementClient 与 CertificateCloudCredentials 结合使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37395913/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com