0

我是天蓝色开发的新手。我有一个 azure 应用程序在本地运行良好,但在 azure 上部署时会抛出 SEHException。使用 Visual Studio 发布时,活动日志显示这两个实例都停留在回收中。我使用远程桌面连接到一个实例,并尝试使用该实例上的浏览器访问应用程序。

我收到以下异常。

Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception

StackTrace:
[SEHException (0x80004005): External component has thrown an exception.]
   RdGetLocalResource(UInt16* , _RD_RESOURCE** ) +0
   _LOCALRESOURCE.GetLocalResourceW(UInt16* name, _LOCALRESOURCE** ppout) +309
   Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetLocalResource(String name, InteropLocalResource& ret) +57
   Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetLocalResource(String localResourceName) +231
   MyApp.Web.Infrastructure.Services.AzureLocalStorageService.GetLocalResourceRootPath(String name) +27
   MyApp.Infrastructure.AzureStorageAccountFactory.Create() +117
   MyApp.IoCConfig.RegisterDependencies() +667
   MyApp.Web.MvcApplication.Application_Start() +260

[HttpException (0x80004005): External component has thrown an exception.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +4058693
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext conext, MethodInfo[] handlers) +191
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +352
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +407
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +375

[HttpException (0x80004005): External component has thrown an exception.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11703936
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4870757

它表明 RoleEnvironment.GetLocalResource 导致错误。还有一个问题,为什么我在调用 RoleEnvironment.GetConfigurationSettingValue("MYKEY") 时会收到 SEHException?在 RoleEnvironment.GetConfigurationSettingValue 上得到相同的异常。但是错误出现在本地环境中。在这里,应用程序在本地环境中运行良好,但在 azure 上失败。可能是什么原因?

这是我的 ServiceDefinition 和 ServiceConfiguration.Cloud 文件

服务定义.csdef

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MyApp.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
  <WebRole name="MyApp.Web" vmsize="ExtraSmall">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
    <Imports>
      <Import moduleName="RemoteAccess" />
      <Import moduleName="RemoteForwarder" />
    </Imports>
    <ConfigurationSettings>
      <Setting name="StorageConnectionString" />
      <Setting name="MediaAccountName" />
      <Setting name="MediaAccountKey" />
    </ConfigurationSettings>
    <LocalResources>
      <LocalStorage name="UploadedVideosCache" cleanOnRoleRecycle="false" sizeInMB="10240" />
      <LocalStorage name="TraceFiles" cleanOnRoleRecycle="true" sizeInMB="50" />
    </LocalResources>
  </WebRole>
</ServiceDefinition>

服务配置.Cloud.cscfg

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="MyApp.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2012-05.1.7">
  <Role name="MyApp.Web">
    <Instances count="2" />
    <ConfigurationSettings>
      <Setting name="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=[accountname];AccountKey=[primary account key]" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="[remoteusername]" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="[encryptedpassword]" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2013-09-15T23:59:59.0000000+05:30" />
      <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
      <Setting name="MediaAccountName" value="[mediaservicesaccountname]" />
      <Setting name="MediaAccountKey" value="[mediaservicesaccountkey]" />
    </ConfigurationSettings>
    <Certificates>
      <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="[thumbprint]" thumbprintAlgorithm="sha1" />
    </Certificates>
  </Role>
</ServiceConfiguration>
4

0 回答 0