3

我试图通过 ARM 将我们的网站连接到 Application Insights 组件,但在将仪器密钥设置为网站应用程序设置时遇到了麻烦。这有时有效,有时无效。

我的猜测是我的dependsOn设置不正确。任何人都可以看看我的模板,看看我是否做错了什么?在网站资源中查看类型为“config”的名为“appSettings”的资源。在这里,我应该等待 Application Insight 完成,然后阅读 Instrumentation Key。

 {
  "name": "[variables('webAppNameFinal')]",
  "type": "Microsoft.Web/sites",
  "location": "[parameters('appServicePlanLocation')]",
  "apiVersion": "2015-04-01",
  "dependsOn": [
    "[concat('Microsoft.Web/serverfarms/', variables('appServicePlanNameFinal'))]"
  ],
  "tags": {
    "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanNameFinal'))]": "Resource",
    "displayName": "webApp"
  },
  "properties": {
    "name": "[variables('webAppNameFinal')]",
    "serverFarmId": "[variables('appServicePlanNameFinal')]"
  },
  "resources": [
    {
      "apiVersion": "2015-04-01",
      "name": "connectionstrings",
      "type": "config",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webAppNameFinal'))]",
        "[resourceId('Microsoft.Sql/servers', variables('sqlServerNameFinal'))]"
      ],
      "properties": {
        "Watches": {
          "value": "[concat('Server=tcp:', reference(concat('Microsoft.Sql/servers/', variables('sqlServerNameFinal'))).fullyQualifiedDomainName, ',1433;Database=', variables('sqlDatabaseNameFinal'), ';User ID=', parameters('sqlServerAdminLogin'), ';Password=', parameters('sqlServerAdminLoginPassword'), ';Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;')]",
          "type": "SQLAzure"
        }
      }
    },
    {
      "apiVersion": "2015-08-01",
      "name": "appsettings",
      "type": "config",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webAppNameFinal'))]",
        "[concat('Microsoft.Insights/components/', variables('applicationInsightsNameFinal'))]"
      ],
      "properties": {
        "Watches.Webjobs.VitecConnect.WatchersExport.Run": "false",
        "ApplicationInsights.InstrumentationKey": "[reference(concat('Microsoft.Insights/components/', variables('applicationInsightsNameFinal'))).InstrumentationKey]"
      }
    },
    {
      "apiVersion": "2015-04-01",
      "name": "web",
      "type": "sourcecontrols",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webAppNameFinal'))]"
      ],
      "properties": {
        "RepoUrl": "[parameters('gitUrl')]",
        "branch": "[parameters('gitBranch')]"
      }
    },
    {
      "apiVersion": "2015-08-01",
      "name": "web",
      "type": "config",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webAppNameFinal'))]"
      ],
      "properties": "[variables('siteProperties')]"
    }
  ]
},
{
  "name": "[variables('applicationInsightsNameFinal')]",
  "type": "Microsoft.Insights/components",
  "location": "Central US",
  "apiVersion": "2014-04-01",
  "dependsOn": [ ],
  "tags": {
    "displayName": "Application Insights"
  },
  "properties": {
    "applicationId": "[variables('webAppNameFinal')]"
  }
},

最好的问候尼古拉斯

4

1 回答 1

0

您是否尝试将dependsOn 放在洞察资源声明中?

在此处查看 web+sql 的快速入门模板:https ://github.com/Azure/azure-quickstart-templates/blob/master/201-web-app-sql-database/azuredeploy.json

他们将dependsOn 放在Insight 声明上,而没有放在网站声明上。这对你有用吗?

{
      "apiVersion": "2015-05-01",
      "name": "[concat('AppInsights', variables('webSiteName'))]",
      "type": "Microsoft.Insights/components",
      "location": "centralus",
      "dependsOn": [
        "[variables('webSiteName')]"
      ],
      "tags": {
        "[concat('hidden-link:', resourceId('Microsoft.Web/sites', variables('webSiteName')))]": "Resource",
        "displayName": "AppInsightsComponent"
      },
      "properties": {
        "ApplicationId": "[variables('webSiteName')]"
      }
    }
于 2016-12-31T17:24:29.530 回答