I am new to azure development. I have a azure application works fine locally, but throws SEHException when deployed on azure. When publishing using Visual Studio, the activity log shows that both the instances are stuck on recycling. I connected to a instance using Remote Desktop and tried accessing the application with browser on that instance.
I am getting the following Exception.
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
It shows that RoleEnvironment.GetLocalResource is causing error. There is another question Why am I getting SEHException when calling RoleEnvironment.GetConfigurationSettingValue("MYKEY")? which gets same exception on RoleEnvironment.GetConfigurationSettingValue. But there the error was in local environment. Here the app tuns fine in Local environment, buts fails on azure. What could be the reason?
Here are my ServiceDefinition and ServiceConfguration.Cloud files
ServiceDefinition.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>
ServiceConfiguration.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>