azure-web-app-service - 从 azure-cli 向 Web App 或 Function App 添加 App Insights 支持

标签 azure-web-app-service azure-functions azure-application-insights azure-cli

有没有办法从 azure-cli 为 Web 应用或函数应用创建和/或激活 App Insights?

现在浏览文档。

最佳答案

我之前也考虑过你的问题。要创建应用程序洞察力,az resource create 似乎是另一个答案中提到的当前唯一可能的方法。但我不确定它是否 100% 有效,您可以尝试一下。

要激活 WebApp 或 FunctionApp 的 Application insight,我们只需在 WebApp 或 FunctionApp 的Application settings 中添加一个名为 APPINSIGHTS_INSTRUMENTATIONKEY 的设置。只需使用下面的命令,它在我这边运行良好。

#retrive the InstrumentationKey of your application insight
$key = az resource show -g <resource group name> -n <appinsight name> --resource-type "Microsoft.Insights/components" --query properties.InstrumentationKey

#set the application insight for function app
az functionapp config appsettings set -g <resource group name> -n <function app name> --settings "APPINSIGHTS_INSTRUMENTATIONKEY = $key"

#set the application insight for web app
az webapp config appsettings set -g <resource group name> -n <web app name> --settings "APPINSIGHTS_INSTRUMENTATIONKEY = $key"

测试样例(web app结果相同):

enter image description here 检查门户:

enter image description here

关于azure-web-app-service - 从 azure-cli 向 Web App 或 Function App 添加 App Insights 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53154397/

相关文章:

azure - 使用 Express Web 应用程序设置 Azure DevOps 源代码控制时出错

visual-studio-2017 - Azure 服务总线触发器队列未在本地调试中命中代码

Azure Functions 指标显示正在运行的并发主机数量

azure - 显示分数低于 60% 的答案 Qna Maker with azure App Insights

azure - 如何在azure门户中配置多级虚拟目录?

Azure轻松身份验证根据AD用户ID获取用户角色ASP.net核心应用程序WebAPI

msbuild - 运行自定义 MSBuild 任务作为 git 部署到 Azure 网站的一部分

azure - 推荐的 Azure 服务来替换 Azure 功能

azure - 我可以查看有关我的 Azure 函数如何扩展的图表或事件日志吗?

reactjs - 如何绕过浏览器加载项阻止 Azure Application Insight 日志