2012-11-21 66 views
1

我目前正在嘗試將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以後,我必須使用我的證書執行額外的步驟嗎?

任何方向將不勝感激。

+0

問題是,這只是爲了找出你是否在生產或階段?否則我假設你已經通過角色配置添加了證書? – f0x

+0

是的,我們使用該檢查來查看我們是否處於生產或分期階段,因爲我們不想在分階段中對我們的工作人員角色運行某些作業。證書已添加到配置文件中,並已上傳到azure。我們可以看到它列在管理門戶的證書下。我們已經上傳了100次,並且都與OSFamily一起正常工作爲1,這個問題只存在於OSFamily爲3. – Eilimint

+0

您是否嘗試過使用StoreLocation.LocalMachine而不是CurrentUser?我認爲這是Azure在將證書上載到託管服務時放置證書的地方。 – Sami

回答

相關問題