Azure,从代码 .NET 中获取应用程序服务详细信息
Azure, get App service details from code .NET
下面的代码运行在Azure App服务上运行获取App数据。
在本地它抛出证书未授权的异常。
有什么原因吗?
如果我从本地字符串创建证书,它工作正常。
public static CertificateCloudCredentials CredentialsProd;
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
prodThumbprint,
false);
if (certCollection.Count > 0)
{
X509Certificate2 cert = certCollection[0];
Credentials = new CertificateCloudCredentials(SUBSCRIPTION_ID, cert);
}
certStore.Close();
using (var client = new ComputeManagementClient(Credentials))
{
var t = client.HostedServices.GetDetailedAsync(serviceName, CancellationToken);
HostedServiceGetDetailedResponse detailedResponse = t.Result;
}
本地计算机上的证书必须安装为 .Pfx
就像在 Azure 中一样。
下面的代码运行在Azure App服务上运行获取App数据。 在本地它抛出证书未授权的异常。 有什么原因吗?
如果我从本地字符串创建证书,它工作正常。
public static CertificateCloudCredentials CredentialsProd;
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
certStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
prodThumbprint,
false);
if (certCollection.Count > 0)
{
X509Certificate2 cert = certCollection[0];
Credentials = new CertificateCloudCredentials(SUBSCRIPTION_ID, cert);
}
certStore.Close();
using (var client = new ComputeManagementClient(Credentials))
{
var t = client.HostedServices.GetDetailedAsync(serviceName, CancellationToken);
HostedServiceGetDetailedResponse detailedResponse = t.Result;
}
本地计算机上的证书必须安装为 .Pfx 就像在 Azure 中一样。