Azure 管理库,证书被拒绝

标签 azure certificate azure-management

我正在尝试使用 Azure 管理库 NuGet 包通过 ComputeManagementClient.UpgradeByNameAsync 升级部署。

我正在使用证书的指纹从证书存储加载它并创建我的凭据,但我的请求不断被拒绝,并显示以下消息:

The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.

我已尽我所能来解决这个问题,但没有任何效果。

我已四重检查我的指纹是否正确,并且证书是否显示在 azure 的管理证书列表中。关于我可能出错的地方有什么想法吗?

最佳答案

public static CertificateCloudCredentials FromPublishSettingsFile(string path, string subscriptionId)
        {
            try
            {
                var profile = XDocument.Load(path);
                var certificate = new X509Certificate2(
                    Convert.FromBase64String(profile.Descendants("PublishProfile").First()
                    .Attribute("ManagementCertificate").Value));
                return new CertificateCloudCredentials(subscriptionId, certificate);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

使用此代码块从发布设置文件创建一个CertificateCloudCredentials 类型的对象。成功创建对象后,使用以下代码块创建computeManagementClient。

var computeManagementClient = new ComputeManagementClient(creds);

虽然计算管理客户端仅接受 SubscriptionCloudCredentials,但 CertificateCloudCredentials 是兼容的并且将被接受。

关于Azure 管理库,证书被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22600905/

相关文章:

azure - 如何将操作组导出到 Azure 中的 ARM 模板?

azure - C# 控制台应用程序可以在 Azure AD 中注册吗

Azure 机器人无法在 Skype 上发布

azure - Microsoft/Azure OAuth 失败,我的组织缺少服务主体

ssl - 如何使用pem文件对jar进行签名?

python - 如何使用 p12 证书连接到 LDAP 服务器

编译编辑好的apk后Android apk安装报错

c# - Azure.通过交互式用户登录进行身份验证 (Microsoft.Azure.Management.Fluent)

c# - 通过 C# Azure 管理库将 SSL 绑定(bind)添加到 Azure 网站

java - Azure Java : cannot add plan information while creating VM