Damola Ojoniyi
5 min readNov 3, 2023

Monitoring your Power Platform Resources with Azure Application Insights (I)

Image credits : https://connamix.com/

Canvas Application Monitoring

Requirements
Azure Account
Azure Subscription

Algorithm
Create an Application Insights resource in Microsoft Azure
Connect your Application insights to your Canvas App
Manage you Analytics and Create Rules

Create Application Insights in Azure Portal

Add Tags
Azure run some background validation {If passed the create option comes up}

Azure provisions an application resource (This might take some minutes)

After your resource is provisioned:
Copy the instrumentation key (This provides the link between your PowerApps to log the application runtime data into the insight resource

After provisioning the app the next things is connecting our canvas application to the resource

Connecting your Canvas Application

Add the instrumentation key to the Canvas app information
Publish your app and look out for new metrics in the azure resource

Some application performance available in Canvas App and Azure Application insights

Collecting User’s Feedback

The application insights can be used to collect users ratings on application performance
In your environment create a component made available for all your app makers collect user to monitor application performance for optimization and improvement
Use the trace function to collect user views on app and log them into the application insights
Create a component add two icons {Smile and Frown}
Smile Control:

User’s feedback

OnSelect Property for the Smile Icon

Trace(                                              //Function
"App Feedback", //Name(This is important for query filters in azure application insights)
TraceSeverity.Information,
{
UserName: User().FullName, //Optional to capture name
UserEmail: User().Email, //Optional to capture the email
FeedbackValue: "1" //Required to know the type of feedback
}
);
Notify("Thanks for your feedback!"); //Notification

Frown Control
Repeat the above code but change the Feedback Value to -1

Trace(                                              //Function
"App Feedback", //Name(This is important for query filters in azure application insights)
TraceSeverity.Information, // Logs the feedback value under severity
{
UserName: User().FullName, //Optional to capture name
UserEmail: User().Email, //Optional to capture the email
FeedbackValue: "-1" //Required to know the type of feedback
}
);
Notify("Thanks for your feedback!"); //Notification

Anytime a user clicks on this a log is created in the application insights for reach response
Note:(Add a disabled variable that is set to DisplayMode.Disabled if either of the icons is selected) — — This will stop multiple entry from a single user or a single session

This can be viewed in the application insights under the logs with a query statement

Adding an alert will be good right
Yes this is good to stay proactive with your apps user
Add an alert sends notification when a user gives your app a frown

Alert for bad reviews

Add the alert to an action group
How to create action groups in azure — https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/action-groups

Monitoring Errors(Some features are currently in Preview and Experimental)

Formula-Level Error
This error occurs with formula and needs some management in your PowerFx with the Error, IfError functions
You can read more about this here: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-iferror

Set this up inside your app to send the logs to your application insights

Turn on Formula-Level Error Management
IfError(              //Error If block
Set( //Actions the If block check
StartScreen,
false
);
Set(
StartScreenButton,
false
),
Trace( //If Error Statement is true
"Formular Error",
TraceSeverity.Error,
{
Message: "Formular Error",
Screen: App.ActiveScreen.Name
}
), //Fallback Action or Expression
)

Unhandled Errors(Experimental in PowerApps)

This will log all unhandled error into your application — Unhandled errors can be identified and distinguished from other error events by the event message “Unhandled error.” The “severityLevel” dimension of these events is 3 (TraceSeverity.Error) (Microsoft 2023)

OnError Property in your App Property

Use OnError to take action after an error has been detected. It provides a global opportunity to intercept an error banner before it’s displayed to the end user and log into the Application insights with the Trace Function

Trace( $"Error {FirstError.Message} in {FirstError.Source}" )

This another option to log Unhandled Errors into the Insights resource

Correlation Error (Experimental in PowerApps)
Correlation error handles error from external sources and custom connectors, this is currently in design to correlate request from apps to external connections and response from the eternal connection services
This will prove useful in monitoring the health status of external connections in your application

Check out how to create a connection your Power Automate resources here

Damola Ojoniyi

#PowerPlatformSysAdmin #DevOps #PowerPlatformDeveloper#Security