首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从azure-cli向WebApp或FunctionApp添加AppInsights支持

从azure-cli向WebApp或FunctionApp添加AppInsights支持
EN

Stack Overflow用户
提问于 2018-11-05 20:25:10
回答 2查看 786关注 0票数 3

是否可以通过azure-cli为WebApp或FunctionApp创建和/或激活AppInsights

现在正在深入研究文档。

EN

回答 2

Stack Overflow用户

发布于 2018-11-05 23:26:28

通过cli https://github.com/Azure/azure-cli/issues/5543创建应用程序洞察资源目前存在一个未解决的问题

您可以看到用户当前是这样创建它们的

代码语言:javascript
复制
az resource create \
    --resource-group $RESOURCE_GROUP \
    --resource-type "Microsoft.Insights/components" \
    --name $NAMESPACE_PREFIX-appinsights \
    --location $PRIMARY_LOCATION \
    --properties '{"ApplicationId":"facerecognition","Application_Type":"other", "Flow_Type":"Redfield", "Request_Source":"IbizaAIExtension"}'

================================================================

根据最新的命令行界面文档(https://docs.microsoft.com/en-us/cli/azure/ext/application-insights/monitor/app-insights?view=azure-cli-latest),您可以使用以下命令创建新的App Insight资源

代码语言:javascript
复制
az monitor app-insights component create --app demoApp --location westus2 --kind web -g demoRg --application-type web
票数 2
EN

Stack Overflow用户

发布于 2018-11-06 15:59:58

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

要激活WebApp或FunctionApp的应用程序洞察,我们只需在WebApp或FunctionApp的应用程序设置中添加一个名为WebApp的设置。只需使用下面的命令,它在我这边运行得很好。

代码语言:javascript
复制
#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应用结果相同):

在门户中进行检查

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53154397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档