是否可以通过azure-cli为WebApp或FunctionApp创建和/或激活AppInsights
现在正在深入研究文档。
发布于 2018-11-05 23:26:28
通过cli https://github.com/Azure/azure-cli/issues/5543创建应用程序洞察资源目前存在一个未解决的问题
您可以看到用户当前是这样创建它们的
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资源
az monitor app-insights component create --app demoApp --location westus2 --kind web -g demoRg --application-type web发布于 2018-11-06 15:59:58
我之前也考虑过你的问题。要创建应用程序洞察力,az resource create似乎是目前唯一可能的方法,正如另一个答案中所提到的那样。但我不确定它是否100%有效,你可以试一试。
要激活WebApp或FunctionApp的应用程序洞察,我们只需在WebApp或FunctionApp的应用程序设置中添加一个名为WebApp的设置。只需使用下面的命令,它在我这边运行得很好。
#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应用结果相同):

在门户中进行检查

https://stackoverflow.com/questions/53154397
复制相似问题