When func.exe
is run from VS, it suggests "For detailed output, run func with --verbose flag."
问题描述
在本地调式Azure Function时候,默认输出的日志都是比较简洁的。如果需要详细的日志输出,可以在启动func命令中添加--verbose参数。那如何来添加呢?
日志输出对比:
开启前日志 | 开启后日志 |
Hosting environment: Production Content root path: /home/pont/projects/fibre-collective/packages/certification Now listening on: http://0.0.0.0:7071 Application started. Press Ctrl+C to shut down. Value cannot be null. (Parameter 'provider') | Azure Functions Core Tools (3.0.2358 Commit hash: d6d66f19ea30fda5fbfe068fc22bc126f0a74168) Function Runtime Version: 3.0.13159.0 [5/19/2020 12:09:26 PM] FUNCTIONS_WORKER_RUNTIME set to node. Skipping WorkerConfig for language:python [5/19/2020 12:09:26 PM] FUNCTIONS_WORKER_RUNTIME set to node. Skipping WorkerConfig for language:java [5/19/2020 12:09:26 PM] FUNCTIONS_WORKER_RUNTIME set to node. Skipping WorkerConfig for language:powershell [5/19/2020 12:09:26 PM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '190e8a62-6b3e-48f1-83d1-a3ede0bce239' [5/19/2020 12:09:26 PM] Reading host configuration file '/home/pont/projects/fibre-collective/packages/certification/host.json' [5/19/2020 12:09:26 PM] Host configuration file read: [5/19/2020 12:09:26 PM] { [5/19/2020 12:09:26 PM] "version": "2.0", [5/19/2020 12:09:26 PM] "logging": { [5/19/2020 12:09:26 PM] "applicationInsights": { [5/19/2020 12:09:26 PM] "samplingExcludedTypes": "Request", [5/19/2020 12:09:26 PM] "samplingSettings": { [5/19/2020 12:09:26 PM] "isEnabled": true [5/19/2020 12:09:26 PM] } [5/19/2020 12:09:26 PM] } [5/19/2020 12:09:26 PM] }, [5/19/2020 12:09:26 PM] "extensionBundle": { [5/19/2020 12:09:26 PM] "id": "Microsoft.Azure.Functions.ExtensionBundle", [5/19/2020 12:09:26 PM] "version": "[1.*, 2.0.0)" [5/19/2020 12:09:26 PM] } [5/19/2020 12:09:26 PM] } [5/19/2020 12:09:26 PM] Reading functions metadata [5/19/2020 12:09:26 PM] 1 functions found [5/19/2020 12:09:26 PM] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /tmp/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle [5/19/2020 12:09:26 PM] Fetching information on versions of extension bundle Microsoft.Azure.Functions.ExtensionBundle available on https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/index.json [5/19/2020 12:09:27 PM] Downloading extension bundle from https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/1.1.1/Microsoft.Azure.Functions.ExtensionBundle.1.1.1.zip to /tmp/d87a8cf9-a864-42f0-a891-b7e41a7d103d/Microsoft.Azure.Functions.ExtensionBundle.1.1.1.zip Hosting environment: Production Content root path: /home/pont/projects/fibre-collective/packages/certification Now listening on: http://0.0.0.0:7071 Application started. Press Ctrl+C to shut down. [5/19/2020 12:11:22 PM] Executing HTTP request: { [5/19/2020 12:11:22 PM] "requestId": "90571ec9-f3f7-4606-b012-62097466c9a3", [5/19/2020 12:11:22 PM] "method": "GET", [5/19/2020 12:11:22 PM] "uri": "/" [5/19/2020 12:11:22 PM] } System.ArgumentNullException: Value cannot be null. (Parameter 'provider') |
开启方式
方式一:在VS Code中修改.vscode\launch.json文件中的启动命令
默认通过VS Code创建一个Java Azure Function的文件目录结构为:
PS C:\Function> tree /f
Folder PATH listing for volume OSDisk
Volume serial number is 4A75-5D11
C:.
│ .classpath
│ .gitignore
│ .project
│ host.json
│ local.settings.json
│ pom.xml
│
├───.settings
│ org.eclipse.core.resources.prefs
│ org.eclipse.jdt.apt.core.prefs
│ org.eclipse.jdt.core.prefs
│ org.eclipse.m2e.core.prefs
│
├───.vscode
│ extensions.json
│ launch.json
│ settings.json
│ tasks.json
在launch.json文件中,添加启动参数 --verbose
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Java Functions",
"type": "java",
"request": "attach",
"hostName": "127.0.0.1",
"port": 5005,
"preLaunchTask": "func: host start --verbose"
}
]
}
点击F5,从VS Code中启动Azure Function,根据提示,在tasks.json也需要添加--verbose参数
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"command": "host start --verbose",
"problemMatcher": "$func-java-watch",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/target/azure-functions/myFunction-0115"
},
"dependsOn": "package"
},
{
"label": "package",
"command": "mvn clean package",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
方式二:直接通过命令行启动Azure Funciton,使用完整命令: func host --verbose
PS C:\Function> func start --verbose
效果展示:

参考资料:
Value cannot be null. (Parameter 'provider'): https://github.com/Azure/azure-functions-core-tools/issues/2232
在 Azure 中使用 Visual Studio Code 创建 Java 函数: https://docs.azure.cn/zh-cn/azure-functions/create-first-function-vs-code-java
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!