【问题标题】:How to get Azure Cloud Service details from App service via Code, .NET如何通过代码、.NET 从 App 服务获取 Azure 云服务详细信息
【发布时间】:2018-06-18 13:25:01
【问题描述】:

在 Azure App 服务中运行以下代码,尝试在同一 Azure 订阅中获取云服务的详细信息,并获取证书与订阅无关的异常。

虽然,在订阅刀片下,在“管理证书”下 证书确实存在并获得授权。

X509Store certStore = new X509Store(StoreName.My, storeLocation);
                    certStore.Open(OpenFlags.ReadOnly);


X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, prodThumbprint, false);
                    if (certCollection.Count > 0)
                        CredentialsProd = new CertificateCloudCredentials(DBConstants.AZURE_SUBSCRIPTION_ID_PROD, certCollection[0]);

        using (var client = new ComputeManagementClient(Credentials))
         {
             var t = client.HostedServices.GetDetailedAsync(serviceName, CancellationToken);
         }

例外:

ForbiddenError:服务器未能验证请求。验证证书是否有效并且与此订阅相关联。

订阅中的证书:

App服务中的证书

【问题讨论】:

    标签: c# .net azure azure-management-api azure-management-portal


    【解决方案1】:

    要使用上传到或导入到应用服务的证书,首先要使其可供您的应用程序代码访问。您可以通过 WEBSITE_LOAD_CERTIFICATES 应用设置来执行此操作。更多详情请参考Use an SSL certificate in your application code in Azure App Service。

    添加一个名为 WEBSITE_LOAD_CERTIFICATES 的应用设置,并将其值设置为证书的指纹。要使多个证书可访问,请使用逗号分隔的指纹值。要使所有证书都可访问,请将值设置为 *。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-04
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 2020-01-21
      • 2017-07-16
      相关资源
      最近更新 更多