我有一个工作区,并使用我的应用程序见解对其进行配置。我在功能的配置中添加了app Insight的仪器密钥和连接字符串。当该功能公开时,应用程序洞察正在运行。但现在监控零件和应用程序洞察仪表板,故障不起作用。缺少什么?
我们可以通过将应用程序洞察配置为我们的功能来获取监控警报和应用程序洞察仪表板、故障,您可以按照以下步骤操作。
然后我在 local.setting.json 文件中使用我的函数配置了 azure 应用程序洞察。
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "python",
"APPINSIGHTS_INSTRUMENTATIONKEY": "your_instrumentation_key_here"
}
}
from applicationinsights import TelemetryClient
import time
# Simulate custom event
client.track_event("FakeEvent", properties={"key": "value"})
# Simulate custom metric
client.track_metric("FakeMetric", 42)
# Simulate exception
try:
# Code that might raise an exception
raise ValueError("Simulated exception")
except Exception as e:
client.track_exception()
# Flush telemetry data
client.flush()
您可以看到运行函数应用程序时生成的异常,并且这些异常在我的应用程序洞察中被跟踪为失败。
仪表板: