代码之家  ›  专栏  ›  技术社区  ›  TreeGlass

调用Azure函数时FunctionInvocationException

  •  0
  • TreeGlass  · 技术社区  · 7 年前

    我的Azure功能有问题。函数无法启动,因为每次都会引发FunctionInvocationException。

    内部异常为InvalidOperationException,消息如下:

    必须为此操作提供PartitionKey

    这两种方法在我的开发、qa和uat环境中都很好——只有生产环境有问题。这两个集合(用于设置和审核)都是在没有分区键的情况下创建的,与每个环境一样。

    System.InvalidOperationException(系统无效操作异常): 在Microsoft.Azure.Documents.Client.DocumentClient+d_347.MoveNext(Microsoft.Azure.Documents.Client,版本=1.11.0.0,区域性=中性,公钥令牌=31bf3856ad364e35)

    编辑:

    {
      "scriptFile": "..\\bin\\Cso.Notification.Function.dll",
      "entryPoint": "Cso.Notification.Function.Program.Run",
      "disabled": false,
      "bindings": [
        {
          "type": "httpTrigger",
          "direction": "in",
          "webHookType": "genericJson",
          "name": "request",
          "methods": [
            "post"
          ]
        },
        {
          "type": "documentDB",
          "name": "subscriberSettings",
          "databaseName": "CSO",
          "collectionName": "Settings",
          "id": "SubscriberSettings",
          "connection": "CsoDocDb",
          "direction": "in"
        },
        {
          "type": "http",
          "direction": "out",
          "name": "res"
        },
        {
          "type": "documentDB",
          "name": "collector",
          "databaseName": "CSO",
          "collectionName": "AuditJSON",
          "connection": "CsoDocDb",
          "direction": "out"
        }
      ]
    }
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   TreeGlass    7 年前

    我找到了答案。我们查询初始值(SubscriberSettings)的其中一个文档使用PartitionKey设置不正确。