升级到windows Azure 2.5时出现问题
本文关键字:5时 问题 Azure windows | 更新日期: 2023-09-27 17:50:30
我尝试通过创建一个新的Azure云服务项目从1.8升级到windows Azure SDK 2.5。但在部署到azure云时出现错误:
Your role instances have recycled a number of times during an update or upgrade operation. This indicates that the new version of your service or the configuration settings you provided when configuring the service prevent the role instances from running. Verify your code does not throw unhandled exceptions and that your configuration settings are correct and then start another update or upgrade operation.
azure SDK 1.8中的旧azure项目工作正常。在本地调试时,我在WebRole.cs(在SDK 1.8中创建)中崩溃了。错误信息是:
An exception of type 'System.NullReferenceException' occurred in OTP.Ring.Web.dll but was not handled in user code
发生在:
diagnosticsConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(60);
所以我认为WebRole.cs应该改变,可能涉及WindowsAzure.Diagnostics。我需要帮助如何改变WebRole.cs。其代码如下:
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
var diagnosticsConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnosticsConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(60);
if (ExtensionMethods.GetConfigurationSetting("loggingLevel") == Common.Logger.LogType.ERROR.ToString())
{
diagnosticsConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Error;
}
else if (ExtensionMethods.GetConfigurationSetting("loggingLevel") == Common.Logger.LogType.DIAGNOSTIC.ToString())
{
diagnosticsConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Warning;
}
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticsConfig);
Logger.LogDiagnostic("Starting WebRole");
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
RoleEnvironment.Changing += RoleEnvironmentChanging;
return base.OnStart();
}
private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)
{
// If a configuration setting is changing
if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))
{
// Set e.Cancel to true to restart this role instance
e.Cancel = true;
}
}
}
请注意,基于代码的诊断配置不再支持启动SDK 2.5。SDK 2.5发行说明中提到了这一点:https://msdn.microsoft.com/en-us/library/azure/dn873976.aspx(请参阅Breaking Changes
部分)。我相信你得到错误是因为这个。
我建议的另一件事是将解决方案升级到SDK 2.6而不是2.5。SDK 2.6于上月底发布,解决了2.5中发现的一些问题。