Azure V1功能应用程序,Cosmos DB触发器,无法查看日志

时间:2018-09-25 06:19:58

标签: azure-functions azure-cosmosdb

我正在添加一个简单的Cosmos DB函数应用程序触发器来对添加或更改的文档执行操作,我可以看到我得到了更改提要,但是简单函数崩溃并显示以下输出,我无法弄清原因,并且不确定如何进一步调试呢?我尚未在函数本身中添加任何逻辑,因为我想确保在我去那里添加更高级的逻辑之前,可以正确触发基本更改提要。

key

函数本身非常简单,如下所示

DocDBTrace Information: 0 : DocumentClient with id 1 initialized at endpoint: https://nwcloud-trstore-test.documents.azure.com/ with ConnectionMode: Direct, connection Protocol: Tcp, and consistency level: null
'func.exe' (CLR v4.0.30319: func.exe): Loaded '\\?\C:\Users\MattDouhan\AppData\Local\AzureFunctionsTools\Releases\1.4.0\cli\edge\x86\edge_nativeclr.node'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
DocDBTrace Information: 0 : RefreshLocationAsync() refreshing locations
DocDBTrace Information: 0 : Set WriteEndpoint https://nwcloud-trstore-test-northeurope.documents.azure.com/ ReadEndpoint https://nwcloud-trstore-test-northeurope.documents.azure.com/
DocDBTrace Information: 0 : DocumentClient with id 2 initialized at endpoint: https://nwcloud-trstore-test.documents.azure.com/ with ConnectionMode: Direct, connection Protocol: Tcp, and consistency level: null
DocDBTrace Information: 0 : RefreshLocationAsync() refreshing locations
DocDBTrace Information: 0 : Set WriteEndpoint https://nwcloud-trstore-test-northeurope.documents.azure.com/ ReadEndpoint https://nwcloud-trstore-test-northeurope.documents.azure.com/
func.exe Warning: 0 : Added stats for partition '0' for which the lease was picked up after the host was started.
The thread 0x4b2c has exited with code 0 (0x0).
The thread 0x3d74 has exited with code 0 (0x0).
The thread 0x15c8 has exited with code 0 (0x0).
The thread 0x442c has exited with code 0 (0x0).
The thread 0x31f0 has exited with code 0 (0x0).
The thread 0x5f4 has exited with code 0 (0x0).
The thread 0x2f10 has exited with code 0 (0x0).
The thread 0x678 has exited with code 0 (0x0).
The thread 0x1b94 has exited with code 0 (0x0).
The thread 0x5a0 has exited with code 0 (0x0).
The thread 0x2558 has exited with code 0 (0x0).
The thread 0x37b4 has exited with code 0 (0x0).
The thread 0x286c has exited with code 0 (0x0).
The thread 0x4cc has exited with code 0 (0x0).
The thread 0x30cc has exited with code 0 (0x0).
The thread 0x3884 has exited with code 0 (0x0).
The thread 0x330 has exited with code 0 (0x0).
The thread 0x4240 has exited with code 0 (0x0).
DocDBTrace Error: 0 : DocumentClientException with status code PreconditionFailed, message: Message: {"Errors":["One of the specified pre-condition is not met"]}, inner exception: null, and response headers: {
"x-ms-last-state-change-utc": "Fri, 21 Sep 2018 22:56:50.384 GMT",
"lsn": "27",
"x-ms-schemaversion": "1.6",
"x-ms-quorum-acked-lsn": "27",
"x-ms-current-write-quorum": "3",
"x-ms-current-replica-set-size": "4",
"x-ms-documentdb-partitionkeyrangeid": "0",
"x-ms-xp-role": "1",
"x-ms-request-charge": "1.24",
"x-ms-serviceversion": " version=2.0.0.0",
"x-ms-activity-id": "11848201-4229-4723-9271-b22e5a2ef0a1",
}
DocDBTrace Error: 0 : Operation will NOT be retried. Current attempt 0, Exception: Microsoft.Azure.Documents.PreconditionFailedException: Message: {"Errors":["One of the specified pre-condition is not met"]}
ActivityId: 11848201-4229-4723-9271-b22e5a2ef0a1, Request URI: rntbd://cdb-ms-prod-northeurope1-fd11.documents.azure.com:14126/apps/4bfa4180-1add-4ab6-9446-56e102bf3194/services/ab30350b-a783-4963-a901-2e32760be93f/partitions/1ee407af-d621-4529-959a-ae738aa64194/replicas/131816515549144981p/
   at Microsoft.Azure.Documents.RntbdTransportClient.ThrowIfFailed(String resourceAddress, StoreResponse storeResponse, Uri physicalAddress, Guid activityId)
   at Microsoft.Azure.Documents.RntbdTransportClient.<InvokeStoreAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<WriteAsync>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<InvokeAsync>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<>c__DisplayClass1.<<InvokeAsync>b__0>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClassf`1.<<ExecuteAsync>b__d>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteAsync>d__18`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.ReplicatedResourceClient.<InvokeAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.StoreClient.<ProcessMessageAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<UpdateAsync>d__320.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentPrivateAsync>d__13a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.Client.DocumentClient.<ReplaceDocumentPrivateAsync>d__132.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<>c__DisplayClass2.<<ExecuteAsync>b__0>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Documents.BackoffRetryUtility`1.<ExecuteRetry>d__1b.MoveNext() 
The program '[17072] func.exe' has exited with code -1 (0xffffffff).

1 个答案:

答案 0 :(得分:0)

Cosmos DB触发器确实正在工作并且没有崩溃。根据连接日志的方式,尝试使用log.Info而不是log.Verbose

在部署时验证您的Azure Functions日志配置,以查看“监视器”选项卡是否显示“函数”执行。这是有关App Insights集成的官方文章:https://github.com/Azure/Azure-Functions/wiki/App-Insights

您应该能够查看查询App Insights的日志:

requests
| where timestamp > ago(30m) 
| summarize count() by cloud_RoleInstance, bin(timestamp, 1m)
| render timechart