无法启动 Azure 辅助角色,异常代码 0xe0434352 & 0xC0000035
Unable to start Azure Worker Role, exception code 0xe0434352 & 0xC0000035
当 运行在模拟器本地运行时,web worker 工作正常。但是,每当我在 Azure VM 上更新我的 Web Worker 运行ning 时,我都会在事件查看器中收到以下异常,并且角色不会启动:
Application: WaWorkerHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AggregateException
Stack:
at System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken)
at System.Threading.Tasks.Task.Wait()
at Foo.PushProcess.WorkerRole.Run()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal()
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.b__2()
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()
Inner Exception: A task was canceled.
Faulting application name: WaWorkerHost.exe, version: 2.6.1198.712, time stamp: 0x54eba731
Faulting module name: KERNELBASE.dll, version: 6.3.9600.17415, time stamp: 0x54505737
Exception code: 0xe0434352
Fault offset: 0x0000000000008b9c
Faulting process id: 0xfb8
Faulting application start time: 0x01d11e3128981a5d
Faulting application path: E:\base\x64\WaWorkerHost.exe
Faulting module path: D:\Windows\system32\KERNELBASE.dll
Report Id: 30631c5c-8a25-11e5-80c6-000d3a22f3ec
Faulting package full name:
Faulting package-relative application ID:
Session "MA_ETWSESSION_WAD_415df88f8a0447178dbd4c18f1349f0e_Foo.PushProcess_Foo.PushProcess_IN_0" failed to start with the following error: 0xC0000035
这是相关代码:
public override void Run()
{
Trace.TraceInformation("Foo.PushProcess is running");
try
{
RunAsync(_cancellationTokenSource.Token).Wait(); // This is where the exceptions point to
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
_runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
_storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
var queueClient = _storageAccount.CreateCloudQueueClient();
_pushQueue = queueClient.GetQueueReference("pushes");
_pushQueue.CreateIfNotExists();
CreatePushBroker();
Trace.TraceInformation("Foo.PushProcess has been started");
return result;
}
private async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
CloudQueueMessage message = null;
try
{
message = _pushQueue.GetMessage();
if (message != null)
{
ProcessItem(message);
}
}
catch (Exception ex)
{
if (message != null && message.DequeueCount > 5)
_pushQueue.DeleteMessage(message);
Trace.TraceError("[WORKER] Retrieval Failure: " + ex);
}
await Task.Delay(1000, cancellationToken);
}
}
请注意,一些代码已被省略,但这就是初始化后的所有代码 运行,并且理论上此异常不会到达。
我完全不知道是什么导致了这个问题。任何帮助将不胜感激 - 即使只是为了帮助我获得有用的例外。
更新
我现在已将我的代码缩减为以下内容 - 它与网络工作者一样简单 - 但我仍然遇到异常。我相信要么是旧的worker被缓存了,要么是部署过程有问题。
public override void Run()
{
Trace.TraceInformation("Foo.PushProcess is running");
try
{
RunAsync(_cancellationTokenSource.Token).Wait(); // This is where the exceptions point to
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
_runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
return result;
}
private async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
// code removed for testing - no work is being done.
await Task.Delay(1000, cancellationToken);
}
}
我试了一下,但最终没能重现。我有来自我部署的 MSDN Azure 映像的 VS 2015 Enterprise (14.0.23107.0 D14REL) 运行 .Net Fx 4.6 版。我安装了 Azure 工具和 SDK 2.8。我使用 .NET Fx 4.5.2 创建了一个新的 Azure 云服务,并添加了一个辅助角色。
我只是 运行 你的一些稀疏代码模板如下:
public class WorkerRole : RoleEntryPoint
{
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private readonly ManualResetEvent runCompleteEvent = new ManualResetEvent(false);
private CloudQueue _pushQueue;
private CloudStorageAccount _storageAccount;
public override void Run()
{
Trace.TraceInformation("WorkerRole1 is running");
try
{
this.RunAsync(this.cancellationTokenSource.Token).Wait();
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
this.runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
_storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
var queueClient = _storageAccount.CreateCloudQueueClient();
_pushQueue = queueClient.GetQueueReference("pushes");
_pushQueue.CreateIfNotExists();
CreatePushBroker();
Trace.TraceInformation("Foo.PushProcess has been started");
return result;
}
private void CreatePushBroker()
{
return;
}
public override void OnStop()
{
Trace.TraceInformation("WorkerRole1 is stopping");
this.cancellationTokenSource.Cancel();
this.runCompleteEvent.WaitOne();
base.OnStop();
Trace.TraceInformation("WorkerRole1 has stopped");
}
private async Task RunAsync(CancellationToken cancellationToken)
{
// TODO: Replace the following with your own logic.
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
CloudQueueMessage message = null;
try
{
message = _pushQueue.GetMessage();
if (message != null)
{
ProcessItem(message);
}
}
catch (Exception ex)
{
if (message != null && message.DequeueCount > 5)
_pushQueue.DeleteMessage(message);
Trace.TraceError("[WORKER] Retrieval Failure: " + ex);
}
await Task.Delay(1000, cancellationToken);
}
}
private void ProcessItem(CloudQueueMessage message)
{
return;
}
}
}
它在本地模拟器中运行没有问题,我继续将它部署到启用了 IntelliTrace 的美国西部,在一个小型实例 VM 上,并且有 n 个部署问题。它在 WA-GUEST-OS-4.26_201511-0 来宾角色图像上 运行,我能够通过 RDP 进入机器,但我没有看到任何相关问题到代码或机器。您是否有任何其他二进制文件可能未包含在您的程序包中,或者可能存在一些未正确定义的依赖项,或者存储帐户命名问题?
这是我的部署日志。如您所见,我从美国东部拉取存储只是为了好玩,这花了大约 7 分钟:
1:11:25 AM - 警告:存在包验证警告。
1:11:26 AM - 正在检查远程桌面证书...
1:11:26 AM - 上传证书...
1:11:42 AM - 应用诊断扩展。
1:12:24 AM - 准备部署 AzureCloudService1 - 11/24/2015 1:11:19 AM 使用服务管理 URL 'https://management.core.windows.net/'...
1:12:24 AM - 正在连接...
1:12:24 AM - 正在验证存储帐户 'ericgoleastus'...
1:12:24 AM - 正在上传包...
1:12:28 AM - 正在创建...
1:13:15 AM - 创建的部署 ID:c5f26568707b46a3bd42466dd0bf7509。
1:13:15 AM - 角色 WorkerRole1 的实例 0 正在创建虚拟机
1:13:15 上午 - 开始...
1:13:32 AM - 正在初始化...
1:14:36 AM - 角色 WorkerRole1 的实例 0 正在启动虚拟机
1:16:11 AM - 角色 WorkerRole1 的实例 0 处于未知状态
1:16:43AM - 角色 WorkerRole1 的实例 0 正忙
详细信息:起始角色...系统正在初始化。 [2015-11-24T01:16:08Z]
1:19:50AM - 角色 WorkerRole1 的实例 0 已准备就绪
1:19:50 AM - 创建的网络应用程序 URL:http://quequetest.cloudapp.net/
1:19:50上午 - 完成。
让我们知道您是否可以在启用 IntelliTrace 的情况下获得更多详细信息。
此致,
埃里克
为了解决这个问题,我只是简单地删除了拥有工作者角色的原始云 VM 实例,重新创建它并重新发布角色。从那时起,它工作得非常好。
我仍然无法确定是什么原因导致了错误,并且在任何其他辅助角色中都没有遇到过类似的问题。我在这里的假设是 VM 存在配置问题,无法通过代码或 Azure 门户进行修改。
当 运行在模拟器本地运行时,web worker 工作正常。但是,每当我在 Azure VM 上更新我的 Web Worker 运行ning 时,我都会在事件查看器中收到以下异常,并且角色不会启动:
Application: WaWorkerHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AggregateException
Stack: at System.Threading.Tasks.Task.Wait(Int32, System.Threading.CancellationToken) at System.Threading.Tasks.Task.Wait()
at Foo.PushProcess.WorkerRole.Run()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal() at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.b__2() 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()Inner Exception: A task was canceled.
Faulting application name: WaWorkerHost.exe, version: 2.6.1198.712, time stamp: 0x54eba731
Faulting module name: KERNELBASE.dll, version: 6.3.9600.17415, time stamp: 0x54505737
Exception code: 0xe0434352
Fault offset: 0x0000000000008b9c
Faulting process id: 0xfb8
Faulting application start time: 0x01d11e3128981a5d
Faulting application path: E:\base\x64\WaWorkerHost.exe
Faulting module path: D:\Windows\system32\KERNELBASE.dll
Report Id: 30631c5c-8a25-11e5-80c6-000d3a22f3ec
Faulting package full name:
Faulting package-relative application ID:
Session "MA_ETWSESSION_WAD_415df88f8a0447178dbd4c18f1349f0e_Foo.PushProcess_Foo.PushProcess_IN_0" failed to start with the following error: 0xC0000035
这是相关代码:
public override void Run()
{
Trace.TraceInformation("Foo.PushProcess is running");
try
{
RunAsync(_cancellationTokenSource.Token).Wait(); // This is where the exceptions point to
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
_runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
_storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
var queueClient = _storageAccount.CreateCloudQueueClient();
_pushQueue = queueClient.GetQueueReference("pushes");
_pushQueue.CreateIfNotExists();
CreatePushBroker();
Trace.TraceInformation("Foo.PushProcess has been started");
return result;
}
private async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
CloudQueueMessage message = null;
try
{
message = _pushQueue.GetMessage();
if (message != null)
{
ProcessItem(message);
}
}
catch (Exception ex)
{
if (message != null && message.DequeueCount > 5)
_pushQueue.DeleteMessage(message);
Trace.TraceError("[WORKER] Retrieval Failure: " + ex);
}
await Task.Delay(1000, cancellationToken);
}
}
请注意,一些代码已被省略,但这就是初始化后的所有代码 运行,并且理论上此异常不会到达。
我完全不知道是什么导致了这个问题。任何帮助将不胜感激 - 即使只是为了帮助我获得有用的例外。
更新
我现在已将我的代码缩减为以下内容 - 它与网络工作者一样简单 - 但我仍然遇到异常。我相信要么是旧的worker被缓存了,要么是部署过程有问题。
public override void Run()
{
Trace.TraceInformation("Foo.PushProcess is running");
try
{
RunAsync(_cancellationTokenSource.Token).Wait(); // This is where the exceptions point to
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
_runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
return result;
}
private async Task RunAsync(CancellationToken cancellationToken)
{
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
// code removed for testing - no work is being done.
await Task.Delay(1000, cancellationToken);
}
}
我试了一下,但最终没能重现。我有来自我部署的 MSDN Azure 映像的 VS 2015 Enterprise (14.0.23107.0 D14REL) 运行 .Net Fx 4.6 版。我安装了 Azure 工具和 SDK 2.8。我使用 .NET Fx 4.5.2 创建了一个新的 Azure 云服务,并添加了一个辅助角色。
我只是 运行 你的一些稀疏代码模板如下:
public class WorkerRole : RoleEntryPoint
{
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private readonly ManualResetEvent runCompleteEvent = new ManualResetEvent(false);
private CloudQueue _pushQueue;
private CloudStorageAccount _storageAccount;
public override void Run()
{
Trace.TraceInformation("WorkerRole1 is running");
try
{
this.RunAsync(this.cancellationTokenSource.Token).Wait();
}
catch (Exception ex)
{
Trace.TraceError("[WORKER] Run error: " + ex);
}
finally
{
this.runCompleteEvent.Set();
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
bool result = base.OnStart();
_storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageConnectionString"));
var queueClient = _storageAccount.CreateCloudQueueClient();
_pushQueue = queueClient.GetQueueReference("pushes");
_pushQueue.CreateIfNotExists();
CreatePushBroker();
Trace.TraceInformation("Foo.PushProcess has been started");
return result;
}
private void CreatePushBroker()
{
return;
}
public override void OnStop()
{
Trace.TraceInformation("WorkerRole1 is stopping");
this.cancellationTokenSource.Cancel();
this.runCompleteEvent.WaitOne();
base.OnStop();
Trace.TraceInformation("WorkerRole1 has stopped");
}
private async Task RunAsync(CancellationToken cancellationToken)
{
// TODO: Replace the following with your own logic.
while (!cancellationToken.IsCancellationRequested)
{
Trace.TraceInformation("Working");
CloudQueueMessage message = null;
try
{
message = _pushQueue.GetMessage();
if (message != null)
{
ProcessItem(message);
}
}
catch (Exception ex)
{
if (message != null && message.DequeueCount > 5)
_pushQueue.DeleteMessage(message);
Trace.TraceError("[WORKER] Retrieval Failure: " + ex);
}
await Task.Delay(1000, cancellationToken);
}
}
private void ProcessItem(CloudQueueMessage message)
{
return;
}
}
}
它在本地模拟器中运行没有问题,我继续将它部署到启用了 IntelliTrace 的美国西部,在一个小型实例 VM 上,并且有 n 个部署问题。它在 WA-GUEST-OS-4.26_201511-0 来宾角色图像上 运行,我能够通过 RDP 进入机器,但我没有看到任何相关问题到代码或机器。您是否有任何其他二进制文件可能未包含在您的程序包中,或者可能存在一些未正确定义的依赖项,或者存储帐户命名问题?
这是我的部署日志。如您所见,我从美国东部拉取存储只是为了好玩,这花了大约 7 分钟:
1:11:25 AM - 警告:存在包验证警告。 1:11:26 AM - 正在检查远程桌面证书... 1:11:26 AM - 上传证书... 1:11:42 AM - 应用诊断扩展。 1:12:24 AM - 准备部署 AzureCloudService1 - 11/24/2015 1:11:19 AM 使用服务管理 URL 'https://management.core.windows.net/'... 1:12:24 AM - 正在连接... 1:12:24 AM - 正在验证存储帐户 'ericgoleastus'... 1:12:24 AM - 正在上传包... 1:12:28 AM - 正在创建... 1:13:15 AM - 创建的部署 ID:c5f26568707b46a3bd42466dd0bf7509。 1:13:15 AM - 角色 WorkerRole1 的实例 0 正在创建虚拟机 1:13:15 上午 - 开始... 1:13:32 AM - 正在初始化... 1:14:36 AM - 角色 WorkerRole1 的实例 0 正在启动虚拟机 1:16:11 AM - 角色 WorkerRole1 的实例 0 处于未知状态 1:16:43AM - 角色 WorkerRole1 的实例 0 正忙 详细信息:起始角色...系统正在初始化。 [2015-11-24T01:16:08Z] 1:19:50AM - 角色 WorkerRole1 的实例 0 已准备就绪 1:19:50 AM - 创建的网络应用程序 URL:http://quequetest.cloudapp.net/ 1:19:50上午 - 完成。
让我们知道您是否可以在启用 IntelliTrace 的情况下获得更多详细信息。
此致, 埃里克
为了解决这个问题,我只是简单地删除了拥有工作者角色的原始云 VM 实例,重新创建它并重新发布角色。从那时起,它工作得非常好。
我仍然无法确定是什么原因导致了错误,并且在任何其他辅助角色中都没有遇到过类似的问题。我在这里的假设是 VM 存在配置问题,无法通过代码或 Azure 门户进行修改。