【问题标题】:RoleEnvironmentException in Microsoft Azure Instance DeploymentMicrosoft Azure 实例部署中的 RoleEnvironmentException
【发布时间】:2013-05-04 21:43:58
【问题描述】:

我正在使用 WCF 服务和 Azure 进行游戏。

我有几个 WCF 服务在 Azure 上成功运行,这个特定的服务一直在正常运行,直到我决定在不同的(现有)云服务下重新部署它。

我在我的 VS 解决方案中将其从云服务 X 的角色下删除,并将其添加到另一个云服务角色。我发布了,当我发布时,我收到异常错误 “未处理的异常:Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException”。有人告诉我,该服务不断被回收。

此消息显示在此 WCF 服务所在实例下的 Azure 管理门户中。我已经在它自己的云服务和具有实例的服务下尝试过它。

查看了有关该问题 (http://blogs.msdn.com/b/davidmcg/archive/2011/03/10/diagnosticmonitor-roleenvironmentexception-was-unhandled.aspx) 和 (http://www.microsofttranslator.com/bv.aspx?from=&to=en&a=http%3A%2F%2Fpul.se%2FBlog-Post-Error-RoleEnvironmentException-was-unhandled_Video-ptFrIOhJU6%2ClWCxfMvJiNbE) 的少量文章

远程处理实例,我在事件查看器中有以下内容:

Application: WaIISHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException
Stack:
   at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

我也发现了:

Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException: error
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetLocalResource(String localResourceName)
   at WCFServiceDataTransfer.AzureLocalStorageTraceListener.GetLogDirectory()
   at WCFServiceDataTransfer.WebRole.OnStart()

但这是 AzureLocalStorageTraceListener 中自动生成的代码。

我怎样才能找到这个问题的根源?

Web.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--  To collect diagnostic traces, uncomment the section below or merge with existing system.diagnostics section.
        To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials.
        To avoid performance degradation, remember to disable tracing on production deployments.
  <system.diagnostics>     
    <sharedListeners>
      <add name="AzureLocalStorage" type="WCFServiceDataTransfer.AzureLocalStorageTraceListener, WCFServiceDataTransfer"/>
    </sharedListeners>
    <sources>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
    </sources> 
   </system.diagnostics> -->
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">        
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <client />
    <services>
      <service behaviorConfiguration="TransferServiceBehavior" name="WCFServiceDataTransfer.TransferService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransferService" contract="WCFServiceDataTransfer.ITransferService">
        </endpoint>
      </service>

    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="TransferService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
          transferMode="Streamed">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

        <behaviors>
      <serviceBehaviors>
        <behavior name="TransferServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500" />

        </behavior>
        <behavior>                   
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
    -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true" executionTimeout="14400"   />   
  </runtime>
</configuration>

进入

public class WebRole : RoleEntryPoint
    {
        public override bool OnStart()
        {
            // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config  
            DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
            diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return base.OnStart();
        }
    }

【问题讨论】:

    标签: wcf azure


    【解决方案1】:

    好的,this 解决了这个问题。 我在 Imports 结束标记下的 ServiceDefinition.csdef 文件中添加了以下内容。它根本不存在,一旦我添加了以下内容并发布了实例就可以启动了。

    使用 1.8 版

    <LocalResources>
       <LocalStorage name="WCFServiceDataTransfer.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" />
    </LocalResources>
    

    帮助某天帮助别人。

    【讨论】:

    • 只是好奇-您是指将&lt;LocalResources&gt;&lt;LocalStorage&gt; 元素更改为具有更大的sizeInMB 值吗?如果是这样,您应该编辑您的答案以明确指出这一点,因此它确实确​​实有一天会帮助其他人。另外,只是好奇您使用的是哪个版本的工具。我上周创建了一个项目(使用 v1.8),我的 sizeInMB 值为 20000。这是你的默认值吗?你把你的值改成什么值了?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    • 2019-01-25
    • 1970-01-01
    • 2012-09-20
    相关资源
    最近更新 更多