Connect Appservice to application insights in a different resource group #2641
Answered
by
brwilkinson
sreejaptfa
asked this question in
Q&A
-
How do we deploy appservice but connect the appservice to application insights in a different resource group? |
Beta Was this translation helpful? Give feedback.
Answered by
brwilkinson
Jun 9, 2021
Replies: 1 comment
-
Hi @sreejaptfa Here are the docs for the Application insights. As you can see you can pass in the reference to the AppInsights via the AppSettings on the site. There are a few different syntaxes that you could use. example 1 - very similar to ARM/json style, just in bicep. var appInsightsName = 'myAppInsights'
var appInsightsID = resourceId('otherRG','Microsoft.insights/components/', appInsightsName)
...
siteConfig: {
appSettings: [
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: reference(AppInsightsID, '2015-05-01').InstrumentationKey
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: reference(AppInsightsID, '2015-05-01').ConnectionString
} example 2 - the bicep way 💪 using 'existing'. var appInsightsName = 'myAppInsights'
var otherRG = 'theOtherResourceGroupName'
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' existing = {
name: appInsightsName
scope: resourceGroup(otherRG)
}
...
siteConfig: {
appSettings: [
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: appInsights.properties.InstrumentationKey
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: appInsights.properties.ConnectionString
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
brwilkinson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @sreejaptfa Here are the docs for the Application insights.
https://docs.microsoft.com/en-us/azure/azure-monitor/app/azure-web-apps?tabs=net#automate-the-creation-of-an-application-insights-resource-and-link-to-your-newly-created-app-service
As you can see you can pass in the reference to the AppInsights via the AppSettings on the site.
There are a few different syntaxes that you could use.
example 1 - very similar to ARM/json style, just in bicep.