- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 F# 中编写一个 http 触发器 Azure 函数,我想绑定(bind)一个 DocumentClient
类型的参数,以便更好地控制在 Cosmos DB 中执行的查询。这是我到目前为止所拥有的:
函数.fs
namespace Functions
open System
open System.Net
open System.Net.Http
open Newtonsoft.Json
open Microsoft.Azure.Documents
open Microsoft.Azure.Documents.Client
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Host
open Microsoft.Azure.WebJobs.Extensions
open Microsoft.Azure.WebJobs.Extensions.DocumentDB
module Function =
let Run(req: HttpRequestMessage, [<DocumentDB>] client: DocumentClient, log: TraceWriter) =
log.Info(sprintf "F# HTTP trigger function processed a request.")
req.CreateResponse(HttpStatusCode.OK)
函数.json
{
"disabled": false,
"scriptFile": "..\\..\\..\\build\\Debug\\Functions\\Functions.dll",
"entryPoint": "Functions.Function.Run",
"bindings": [
{
"direction": "in",
"type": "httpTrigger",
"authLevel": "anonymous",
"name": "req",
"methods": [ "get" ],
"route": "users"
},
{
"direction": "in",
"type": "documentDB",
"name": "client",
"connection": "COSMOSDB_CONNECTION_STRING"
},
{
"direction": "out",
"type": "http",
"name": "res"
}
]
}
主机.json
{
"frameworks": {
"net46":{
"dependencies": {
"Dynamitey": "1.0.2",
"FSharp.Interop.Dynamic": "3.0.0",
"Microsoft.Azure.DocumentDB": "1.17.0",
"Microsoft.Azure.WebJobs.Extensions.DocumentDB": "1.0.0"
}
}
}
}
本地.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsDashboard": "",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"COSMOSDB_CONNECTION_STRING": "AccountEndpoint=https://localhost:8081;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;"
}
}
我正在使用开发存储和 Cosmos DB 模拟器在本地运行该函数。我尝试将其描述的内容翻译为 F# here对于 C#。而且它也与提到的here几乎相同。 。但我只收到错误 Microsoft.Azure.WebJobs.Extensions.DocumentDB:绑定(bind)到 DocumentClient 属性时需要“Id”
。
最佳答案
this issue on Github 中提到了一种解决方法。它已修复在tooling中并将在下一个版本中提供
从 github 复制的解决方法
I found the issue and filedhttps://github.com/Azure/azure-functions-cli/issues/206. The easiestworkaround until we have an update:
Go to
C:\Users\{user}\appdata\local\Azure.Functions.Cli\1.0.0
.Open
func.exe.config
in notepad.Find this:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Azure.Documents.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.11.0.0" newVersion="1.11.0.0" />
</dependentAssembly>In both places, replace
1.11.0.0
with1.13.0.0
so you end up with:<dependentAssembly>
<assemblyIdentity name="Microsoft.Azure.Documents.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.13.0.0" newVersion="1.13.0.0" />
</dependentAssembly>Save and retry.
关于azure - Azure 函数参数中的 DocumentClient 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45804576/
如果我直接在桌面应用程序中使用 DocumentClient,则会暴露与构建文档客户端时使用的 api key 相关的安全问题。似乎没有办法保护 key 。将 key 带入客户端可能会导致黑客完全控制
我遇到一种情况,我需要检索特定文档,但我不知道它是 PartitionKey。 该方法如下所示: public async Task GetItemAsyncNoGroupId(string
我遇到一种情况,我需要检索特定文档,但我不知道它是 PartitionKey。 该方法如下所示: public async Task GetItemAsyncNoGroupId(string
DocumentClient 线程安全吗? 我收到了混合消息: 来自 MSDN https://msdn.microsoft.com/library/azure/microsoft.azure.doc
为什么没有 CreateDocumentQuery 的异步版本? 这个方法例如可以是异步的: using (var client = new DocumentClient(new Uri(en
我正在尝试遵循 azure DocumentDb 快速启动项目。我将要开发的应用程序将在 WPF 中而不是在控制台中,因此为了加快 documentdb 的速度,我创建了一个新的 wpf 项目 (.N
我在本地使用 DynamoDB,可以创建和删除表。我创建了一个只有一个键的表,如下所示 const tablePromise = dynamodb.listTables({}) .promis
我有一个 Azure Function v2,它调用一个实用程序库,该库又实例化一个 DocumentClient。当在本地运行我的函数时,它会在此行引发异常: _client = new Docum
Cosmos 入门和文档 db/sql。为什么这不起作用?我可以看到,没有抛出任何错误。有数据应该返回。 private const string EndpointUri = "some ur
我可能在这里遗漏了一些明显的东西,但是...我正在尝试使用 DocumentClient.UpsertDocumentAsync(...) 更新插入到 CosmosDB 中。问题是,我无法创建 Doc
我正在 F# 中编写一个 http 触发器 Azure 函数,我想绑定(bind)一个 DocumentClient 类型的参数,以便更好地控制在 Cosmos DB 中执行的查询。这是我到目前为止所
如何在 docClient.get() 之外获取 data.Item.Name 以便在其他函数中进一步使用它。 const docClient = new awsSDK.DynamoDB.Docume
祝大家感恩节快乐!我正在编写一个调用 DynamoDB 的 lambda 函数,但我遇到了设计/实现问题。 我有以下代码结构: exports.handler = function(event, co
所以我正在运行一些单元测试,我想从根本上消除 promise ,以便它在我想要的时候解决或拒绝。这是我的代码的样子。 getStatusForPromiseID = async (promiseId,
我尝试从 aws-sdk 使用 Amazons DocumentClient for AWS.dynamodb。我还使用 Amazon 的标准 node.js 虚拟机:“64 位 Amazon Lin
我正在使用 AWS.DynamoDB.DocumentClient,在本地使用 Dynamodb(端口 8080)。当我执行放置时,回调中的 data 变量是一个空对象。我错过了什么吗? import
我正在为下面的代码编写单元测试,它使用带有 where(filter) 条件的文档客户端 CreateDocumentQuery 方法。 var documentQuery = ReadOnlyDo
我的哈希键是一个名为 pid 的数字 这是代码 app.get('/register', (req, res) => { var params = { TableName:"passengers"
我是 DynamoDB 的新手。 当我使用 AWS.DynamoDB.DocumentClient 类从表中读取数据时,查询有效,但我得到的结果格式错误。 询问: { TableName: "us
这个问题与 DocumentClient 中的 Microsoft.Azure.DocumentDB.Core v2.11.2 相关。 (更新:该错误也存在于 Microsoft.Azure.Cosm
我是一名优秀的程序员,十分优秀!