【发布时间】:2018-11-06 18:59:00
【问题描述】:
我在 Azure Function (V2) 中运行以下代码;
new DocumentClient(new Uri(keys.dbEndPoint), keys.dbPrimaryKey);
直到今天,它在 localhost 上的 azure 函数中运行良好,没有改变任何东西我现在得到以下异常:
数据 [IDictionary]:{System.Collections.ListDictionaryInternal} HResult [int]:-2146233036 HelpLink [string]:null InnerException [异常]:{System.NullReferenceException:未设置对象引用 到一个对象的实例。} Message [string]:"类型初始化器 对于“Microsoft.Azure.Documents.UserAgentContainer”抛出了一个 异常。" 源 [字符串]:"Microsoft.Azure.DocumentDB.Core" StackTrace [字符串]:”在 Microsoft.Azure.Documents.UserAgentContainer..ctor()\r\n at Microsoft.Azure.Documents.Client.ConnectionPolicy..ctor()\r\n at Microsoft.Azure.Documents.Client.ConnectionPolicy.get_Default()\r\n
在 Microsoft.Azure.Documents.Client.DocumentClient.Initialize(Uri serviceEndpoint, ConnectionPolicy connectionPolicy, Nullable1 desiredConsistencyLevel)\r\n at Microsoft.Azure.Documents.Client.DocumentClient..ctor(Uri serviceEndpoint, String authKeyOrResourceToken, ConnectionPolicy connectionPolicy, Nullable1 desiredConsistencyLevel)\r\n at Platform.AzureConfig.get_Database() 在 D:\DeansCloud\AzureConfig.cs:line 60" TargetSite [MethodBase]:{Void .ctor()} 类型名称 [string]:"Microsoft.Azure.Documents.UserAgentContainer" 静态成员 非公众成员
话不多说,内部异常提到了空引用异常:
消息[字符串]:“对象引用未设置为对象的实例。”
这是 azure cosmos db 现在的问题吗?我需要更新一些东西吗?
【问题讨论】:
-
您使用的是哪个 Functions 版本? v1 还是 v2?另外,您能否添加更多代码来如何在函数中实例化 DocumentClient?通过绑定还是手动?
-
@silent V2 和手动
标签: c# azure azure-functions azure-cosmosdb