我目前正在尝试将我们的 Azure 云服务(Web 和 Worker 角色)升级到 .Net 4.5 Framework。 为此,我们必须将 Azure 部署从 Windows Server 2008 更改为 Windows Server 2012。
这需要我们在 ServiceConfiguration 文件中将 OSFamily 从“1”更改为“3”。
当前系统
- .Net 4.0
- MVC3
- EF 4.4
- Azure 工具 1.6
- Visual Studio 2010
- Windows Server 2008
系统升级
- .Net 4.5
- MVC4
- EF 5
- Azure 工具 1.8
- Visual Studio 2012
- Windows Server 2012
当我们查询 Azure 证书以确定我们处于“生产”环境还是“暂存”环境时,我遇到了问题。
以下代码行查找证书。 为了清晰起见,缩短了。
// Open the certificate store for the current user.
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly);
foreach (var cert in certStore.Certificates)
{
OutputToFile.OutputDataReceived("Cert - " + cert.FriendlyName + " -- Thumb -- " + cert.Thumbprint);
}
// Find the certificate with the specified thumbprint.
X509Certificate2Collection certCollection = certStore.Certificates.Find(
X509FindType.FindByThumbprint,
thumbPrint,
false);
// Close the certificate store.
certStore.Close();
如您所见,我将证书详细信息打印到日志文件中,以查看哪里发生了故障。 在 OSFamily="1"(Windows Server 2008) 上,此功能完美运行。它找到证书。
但是,当我设置 OSFamily="3"(Windows Server 2012) 时,日志文件不会打印循环中的证书详细信息。
它在本地也运行良好。
这是 Windows Server 2012 的问题还是 Azure 部署的问题? 迁移到 Windows Server 2012 后,我是否必须对我的证书执行额外的步骤?
任何方向将不胜感激。
最佳答案
我在这里找到了问题的答案:Azure Autoscaling works locally but not when deployed
在 OS Family 3 中,WaWorkerHost 运行在“NETWORK SERVICE”帐户下,该帐户没有私钥访问权限。所以我需要以更高的权限运行该角色。
关于.net - Azure 无法在 Windows Server 2012 辅助角色上找到证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13496327/