【问题标题】:Azure - This Service is unhealthy .NET BackendAzure - 此服务是不健康的 .NET 后端
【发布时间】:2015-08-13 09:06:46
【问题描述】:

我已经使用 webapi2.2 构建了一个 API。

当我将 API 部署到 Azure 时,我收到服务不健康消息...当我检查我的 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 标头授权机制?

【问题讨论】:

    标签: c# asp.net azure asp.net-web-api2


    【解决方案1】:

    我找到了解决方案 - 我认为问题是由于我的 Azure 帐户中正在运行另一个移动服务应用程序造成的。该应用程序是在 2015 年初构建的,并且使用了没有参数的注册过程

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

    我认为这可能会混淆服务操作(一个应用程序有一个没有参数的寄存器,而另一个应用程序有一个只有一个参数的寄存器)。为了解决我的新应用程序的问题,我删除了配置参数,并在注册函数中构建配置设置,见下文

      public static void Register()
        {
    
            ConfigOptions options = new ConfigOptions();
    
            HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));
            config.EnableCors();.....
    

    请记住,尽管您需要访问 using Microsoft.WindowsAzure.Mobile.Service 命名空间...这可以通过安装 nuget 包 WindowsAzure.MobileServices.Backend 来获得

    希望这对有类似问题的人有所帮助

    【讨论】:

      猜你喜欢
      • 2023-01-24
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 2022-10-20
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      • 2017-01-10
      相关资源
      最近更新 更多