In a bicep file for an App Service, I want to grab the id and key from an existing Log Analytic Workbench, created in another repo/bicep file.
I see this is possible in Terraform, but cannot find any docs on how to achieve this with Bicep, which seems a bit odd.
What I thought should be possible would be something like this;
// Refer to existing Log Analytics Workbench
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
name: logAnalyticsWorkspaceName
}
and then doing something like;
logAnalyticsWorkspace.properties.keys.primary_shared_key
Any tips?
you would need to use the listKeys function:
// Get a reference to the existing log analytics workspace
resource logAnalyticWorkspace 'Microsoft.OperationalInsights/workspaces@2021-06-01' existing = {
name: logAnalyticWorkspaceName
}
var primaryKey = logAnalyticWorkspace.listKeys().primarySharedKey