升级Azure SDK 2.5后总是调用WindowsAzure.ServiceRuntime.DefaultEntryPoint

本文介绍了一个 Azure WorkRole 项目从 Azure SDK 2.4 升级到 2.5 后无法启动的问题及解决办法。升级后,在本地 Azure Emulator 和生产环境中均无法正常启动,通过调试输出信息发现 Azure Emulator 调用了 ServiceRuntime 中的 DefaultEntryPoint 而未执行自定义 RoleEntryPoint。最终发现是由于项目中引用了不同版本的 Azure SDK 所致。

    最近将一个Azure Work Role项目由Azure SDK2.4 升级到了2.5。在升级完毕后,发现该Work Role项目无论是部署在本地的Azure emulator中还是Azure 生产环境上,都无法正常启动。在本地的Emulator中调试时,OnStart()中设置断点也无法走到,让人感觉非常费解,因为没有做过任何代码的修改,仅仅是升级了Azure SDK而已。在Visual Studio中的Output看到了如下的调试输出信息:


Microsoft.WindowsAzure.ServiceRuntime Information: 200 : Role entrypoint . CALLING   OnStart():Microsoft.WindowsAzure.ServiceRuntime.DefaultEntryPoint
Microsoft.WindowsAzure.ServiceRuntime Information: 202 : Role entrypoint . COMPLETED OnStart(): Microsoft.WindowsAzure.ServiceRuntime.DefaultEntryPoint
The thread 0x9210 has exited with code 259 (0x103).
Microsoft.WindowsAzure.ServiceRuntime Information: 203 : Role entrypoint . CALLING   Run(): Microsoft.WindowsAzure.ServiceRuntime.DefaultEntryPoint
Microsoft.WindowsAzure.ServiceRuntime Verbose: 500 : Role instance status check starting
Microsoft.WindowsAzure.ServiceRuntime Verbose: 502 : Role instance status check succeeded: Ready
Microsoft.WindowsAzure.ServiceRuntime Warning: 204 : Role entrypoint . COMPLETED Run() ==> ROLE RECYCLING INITIATED: Microsoft.WindowsAzure.ServiceRuntime.DefaultEntryPoint
Microsoft.WindowsAzure.ServiceRuntime Information: 503 : Role instance recycling is starting
The thread 0xa100 has exited with code 259 (0x103).
Microsoft.WindowsAzure.ServiceRuntime Information: 205 : Role entrypoint . CALLING   OnStop(): Microsoft.WindowsAzure.ServiceRuntime.DefaultEntryPoint
Microsoft.WindowsAzure.ServiceRuntime Information: 205 : Role entrypoint . CALLING   OnStopping()
Microsoft.WindowsAzure.ServiceRuntime Information: 206 : Role entrypoint . COMPLETED OnStop(): Microsoft.WindowsAzure.ServiceRuntime.DefaultEntryPoint


       不难看出,Azure emulator一直在调用ServiceRuntime中自带的DefaultEntryPoint,压根就没有执行到我程序中定义的继承于RoleEntryPoint的类。也就是,Azure emulator/Azure没有找到我的work role文件中定义的RoleEntryPoint。

       这是为啥呢? 仔细想想,原来为了抽象出RoleEntryPoint,我们特地在其上继承出另外一个类WorkRoleBase,并将它作为一个单独库项目,以便于其它类似WorkRole项目使用。但这个库项目仍然使用的是Azure SDK 2.4,再将它也升级到2.5之后,该Work Role就可成功部署了。所以,之前的出现的问题很有可能是因为同时引用到两个不同版本的的Azure SDK造成。


/// <summary>
/// Worker role project using Azure SDK 2.5
/// </summary>
public sealed class WorkerRole : WorkerRoleBase
{
}


/// <summary>
/// Worker role library using Azure SDK 2.4
/// </summary>
public abstract class WorkerRoleBase : RoleEntryPoint
{
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值