Move Log Analytics Reader role to ai-project.bicep#60
Open
pamelafox wants to merge 1 commit intoAzure-Samples:mainfrom
Open
Move Log Analytics Reader role to ai-project.bicep#60pamelafox wants to merge 1 commit intoAzure-Samples:mainfrom
pamelafox wants to merge 1 commit intoAzure-Samples:mainfrom
Conversation
The role assignment was inside the applicationInsights module, which is gated on shouldCreateAppInsights. After the first azd up, the App Insights connection string output gets saved as an azd env var, which flows back into existingApplicationInsightsConnectionString on subsequent provisions. This makes shouldCreateAppInsights=false, so the entire module--including the role assignment--is skipped on re-provision. Move the role assignment to ai-project.bicep conditioned on enableMonitoring, which is always true when monitoring is active regardless of whether App Insights was freshly created or pre-existing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Log Analytics Reader role assignment needs to be created for both new and existing App Insights resources. Currently (added in #57), it's inside the
applicationInsightsmodule, which is gated onshouldCreateAppInsights. That condition isfalsewhenever an existing App Insights connection string is provided — including on re-provisions, sinceazdsaves the first deploy's outputs as env vars that flow back as "existing" parameters.This means the role assignment is only created on a completely fresh first-time deploy. On any subsequent provision — or when using a pre-existing App Insights — continuous evaluation fails with:
Fix: Move the role assignment from applicationinsights.bicep to ai-project.bicep, gated on
enableMonitoringinstead ofshouldCreateAppInsights. This ensures the project managed identity gets Log Analytics Reader regardless of whether App Insights is newly created or pre-existing.