Scenario: Monitor your applications logs, analytics and alerts.
Solution:
Azure Application Insights provides analytical data about your application. You create a new resource to monitor a new application. Then use instrumentation key to configure the Application Insights SDK, which links your telemetry to the resource.
- Navigate -> Azure portal
- Search -> Application Insights
- Name
- Resource Group
- Region
- Mode [
Classic
orWorkspace-based
] - Review + Create
- Search for the newly created application Insights and copy the instrumentation key [Connection Strings]
- In Project -> appsettings.json add below "ApplicationInsights": { "ConnectionString": "InstrumentationKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }
- Enable Application Insights [server-side telemetry]
- Project > Add Application Insights Telemetry
- Select subscription -> Resource > Register.
- Nuget package -> Microsoft.ApplicationInsights.AspNetCore, should have been added
- Enable for web applications [client-side telemetry]
- _ViewImports.cshtml -> @inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
- _Layout.cshtml -> @Html.Raw(JavaScriptSnippet.FullScript)</head>
- On application run telemetry would start flowing
- Live Metrics- Machine metrics.
- ILogger logs - Application logs
No comments:
Post a Comment