2015-10-20 34 views
2

我试图通过ARM将我们的网站连接到Application Insights组件,但在将Intstrumentation Key设置为网站应用程序设置方面存在麻烦。这有时候并且有时候不行。DependsOn在ARM模板中失败

我的猜测是,即时通讯有不正确的dependsOn设置。任何人都可以看看我的模板,看看我是否做错了什么?查看网站资源中名为“appSettings”的资源类型为“config”的资源。在这里,我应该等待完成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')]" 
    } 
}, 

最佳reagards 尼克拉斯

+0

它不起作用时的行为是什么?任何错误? – BenV

+0

嗨本,行为是,即时通讯设置试图设置,“ApplicationInsights.InstrumentationKey”没有设置att所有。网站创建时没有这个键/值。 –

+0

我遇到类似问题,有关此问题的任何更新? – Marko

回答

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')]" 
     } 
    }