Azure未能在Windows Server 2012工作者角色上找到证书
问题描述:
我目前正在尝试将Azure云服务(Web和Worker角色)升级到.Net 4.5 Framework。 为此,我们必须将Azure部署从Windows Server 2008更改为Windows Server 2012.Azure未能在Windows Server 2012工作者角色上找到证书
这要求我们在ServiceConfiguration文件中将OSFamily从“1”更改为“3”。
当前系统
- .NET 4.0
- MVC3
- EF 4.4
- Azure工具1.6
- Visual Studio 2010中
- 的Windows Server 2008
Upgrad编辑系统
- .NET 4.5
- MVC4
- EF 5
- Azure工具1.8
- 的Visual Studio 2012
- Windows Server 2012中
我遇到了一个问题当我们查询Azure证书来确定我们是否处于“Production”或“Staging”环境时。
以下代码行查找证书。 为了清晰起见缩短。
// 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家庭3,WaWorkerHost是“网络服务”帐户下运行,该帐户没有私有密钥访问权限。所以我需要用提升的权限运行角色。
问题是,这只是为了找出你是否在生产或阶段?否则我假设你已经通过角色配置添加了证书? – f0x
是的,我们使用该检查来查看我们是否处于生产或分期阶段,因为我们不想在分阶段中对我们的工作人员角色运行某些作业。证书已添加到配置文件中,并已上传到azure。我们可以看到它列在管理门户的证书下。我们已经上传了100次,并且都与OSFamily一起正常工作为1,这个问题只存在于OSFamily为3. – Eilimint
您是否尝试过使用StoreLocation.LocalMachine而不是CurrentUser?我认为这是Azure在将证书上载到托管服务时放置证书的地方。 – Sami