2015-08-13 135 views
0

我已经使用webapi2.2构建了一个API。Azure - 此服务不健康.NET后端

当我部署API天青我得到的服务不健康的消息......当我检查我的API的日志,该日志提供错误消息

“自举失败:执行“WebApiConfig.Register “导致了 异常: '参数计数不匹配'

启动应用程序的功能是低于

protected void Application_Start() 
    { 
     AreaRegistration.RegisterAllAreas(); 

     WebApiConfig.Register(GlobalConfiguration.Configuration); 

和我WebApiConfig.cs有以下几点:

public static void Register(HttpConfiguration config) 
    { 
     config.EnableCors(); 

     config.Formatters.JsonFormatter. 
        SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));....... 

另一个问题在这里:该API实现自己的安全机制(我用下面作为参考http://bitoftech.net/2014/12/15/secure-asp-net-web-api-using-api-key-authentication-hmac-authentication/)。此实现是否可以在Azure中使用,或者您是否必须使用x-zumo标头授权机制?

回答

0

我发现了这个问题的解决方案 - 我相信问题是由于我有另一个移动服务应用程序在我的Azure帐户中运行。这个应用程序是一段时间以前建 - 2015年初和不带参数使用该注册流程

public static void Register(){.....} 

我想,这可能混淆了服务操作(即一个应用程序有一个寄存器不带参数,另一个有一个事实注册一个参数)。要解决我的新应用程序的问题,我删除了配置参数,并建立在寄存器功能的配置设置见下文

public static void Register() 
    { 

     ConfigOptions options = new ConfigOptions(); 

     HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options)); 
     config.EnableCors();..... 

但请记住,你将需要访问使用Microsoft.WindowsAzure.Mobile.Service命名空间。 ..这可以通过安装nuget包获得WindowsAzure.MobileServices.Backend

希望这可以帮助有类似问题的人