0
以下代碼在Azure App服務上運行時運行並獲取應用數據。 本地它拋出證書未經授權的例外。 有什麼理由嗎?Azure,從代碼獲取應用服務詳細信息.NET
如果我從字符串本地創建證書,它工作正常。
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;
}