How to Set Up Azure Application Insights for Your Power Apps Code App (Step-by-Step Guide)
How to Set Up Azure Application Insights for Your Power Apps Code App
If you're building code apps in Power Apps, you need visibility into how your application is performing in the real world. Crashes, slow load times, and unhandled errors can silently erode user trust — and without proper monitoring, you'll never know they're happening. That's where Azure Application Insights comes in.
In this step-by-step guide, you'll learn exactly how to connect Azure Application Insights to your Power Apps code app so you can start collecting telemetry, diagnosing issues faster, and building more reliable applications.
What Is Azure Application Insights?
Azure Application Insights is a powerful telemetry and monitoring service within the Azure ecosystem. It helps developers collect, analyze, and act on detailed performance and usage data from their applications. When integrated with a Power Apps code app, it provides:
- Real-time performance monitoring
- Automatic exception and error tracking
- Custom event and metric logging
- User behaviour and session analytics
- Dependency tracking (API calls, database queries, etc.)
For teams managing enterprise-grade solutions, this level of observability is essential. If you'd like help designing a robust monitoring strategy, explore our consulting services.
Prerequisites
Before you begin, make sure you have the following in place:
- An active Azure subscription
- An existing Power Apps code app (or one in development)
- Appropriate permissions to create resources in your Azure resource group
- Basic familiarity with the Azure portal
Step 1: Create an Application Insights Resource in Azure
The first step is to provision an Application Insights resource inside your Azure portal.
- Sign in to the Azure Portal at portal.azure.com.
- In the search bar, type Application Insights and select it from the results.
- Click + Create to start a new resource.
- Fill in the required fields:
- Subscription: Select your Azure subscription.
- Resource Group: Choose an existing group or create a new one.
- Name: Give your resource a descriptive name (e.g.,
MyCodeApp-AppInsights). - Region: Select the region closest to your users.
- Resource Mode: Choose Workspace-based (recommended).
- Click Review + Create, then Create.
Once the deployment is complete, navigate to the resource and copy your Instrumentation Key and Connection String — you'll need these in the next steps.
Step 2: Install the Application Insights SDK in Your Code App
Depending on the language or framework your Power Apps code app uses, you'll need to install the appropriate Application Insights SDK.
For JavaScript / TypeScript Apps
Run the following command in your project terminal:
npm install @microsoft/applicationinsights-web
For .NET / C# Apps
dotnet add package Microsoft.ApplicationInsights.AspNetCore
Always use the latest stable version of the SDK to ensure you have the most up-to-date features and security patches.
Step 3: Initialise Application Insights in Your App
Once the SDK is installed, you need to initialise it using your Connection String from Step 1.
JavaScript / TypeScript Example
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
const appInsights = new ApplicationInsights({
config: {
connectionString: 'YOUR_CONNECTION_STRING_HERE',
enableAutoRouteTracking: true
}
});
appInsights.loadAppInsights();
appInsights.trackPageView();
C# / .NET Example
In your Program.cs or Startup.cs:
builder.Services.AddApplicationInsightsTelemetry(
options => options.ConnectionString = "YOUR_CONNECTION_STRING_HERE"
);
Security tip: Never hard-code your Connection String directly in source code. Store it in environment variables or Azure Key Vault instead.
Step 4: Track Custom Events and Exceptions
Out-of-the-box telemetry is a great start, but the real power of Application Insights comes from custom tracking. You can log business-specific events, user actions, and handled exceptions.
Logging a Custom Event
appInsights.trackEvent({ name: 'UserSubmittedForm', properties: { formId: '123' } });
Logging an Exception
try {
// Your app logic
} catch (error) {
appInsights.trackException({ exception: error });
}
Custom telemetry like this can be invaluable when troubleshooting issues in production environments. Our team regularly helps clients instrument their Power Platform solutions for maximum observability.
Step 5: Verify Telemetry in the Azure Portal
After deploying your updated app, it's time to confirm that data is flowing correctly into Application Insights.
- Navigate to your Application Insights resource in the Azure Portal.
- Click on Live Metrics to see real-time data as you interact with your app.
- Use the Logs (KQL) section to query your telemetry data.
- Check Failures and Performance blades for automated insights.
If you see data appearing — congratulations! Your integration is working correctly.
Best Practices for Using App Insights with Power Apps
- Use sampling to control costs on high-traffic applications.
- Set up Alerts to notify your team when error rates spike or performance degrades.
- Create Dashboards in Azure to share visibility with stakeholders.
- Correlate with Power Automate flows — if your app triggers Power Automate workflows, instrument those too for end-to-end tracing.
- Use Application Maps to visualise dependencies between services.
- Regularly review your retention settings and pricing tier to manage costs.
Troubleshooting Common Issues
No Data Appearing in App Insights
- Double-check your Connection String is correct and not truncated.
- Ensure
loadAppInsights()is called before any tracking methods. - Check browser console or application logs for SDK errors.
- Note that there can be a 2–5 minute delay before data appears in the portal.
High Volume of Telemetry / Unexpected Costs
- Enable Adaptive Sampling in your SDK configuration.
- Review which events you're tracking and remove any redundant logging.
- Set a daily data cap in your App Insights resource settings.
Take Your Power Platform Monitoring Further
Azure Application Insights is just one piece of a comprehensive Power Platform monitoring strategy. Combined with the right architecture and development practices, it gives your team the confidence to ship faster and resolve issues before they impact users.
Whether you're just getting started with code apps or scaling an enterprise deployment, the CRMONCE team can help you design and implement a monitoring and observability strategy that fits your needs.
Ready to Build More Reliable Power Apps?
Our certified Power Platform specialists can help you instrument your applications, optimise performance, and build robust monitoring pipelines — so you spend less time firefighting and more time delivering value.