2015-08-13 134 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

希望這可以幫助有類似問題的人