This post is a drill down into Connection References, what they are and how to use them most effectively with Power Automate
What are Connection References?
Connection references act as a link between actions in Power Automate and the actual connections to data sources. This prevents the need to hard-code a connection into each action in a flow because a connection reference allows you to reference it instead. This provides easy reusability and flexibility because multiple actions can use the same connection reference and hence the same connection.
Connection references can only be created inside a solution. This restriction ensures better control and management of connection references across environments, aligning with Application Lifecycle Management (ALM) best practices.
How to Create Connections and Connection References
Use connection references when flows interact with Microsoft data sources such as Dataverse, SharePoint, SQL Server, or third-party APIs.
Creating a Connection
First of all, a connection reference needs a connection. Connections are created outside of a solution and because the are not solution aware, they are specific to an environment.
To create a connection, select Connections > New connection.
Clicking on See Details provide information about the connection including the apps and flows in which it is used
Creating a Connection Reference
Connection references can be created from inside a Power Automate action, but doing this doesn’t allow a custom name to be assigned. It is better in my view to pre-create connection references and give them appropriate names, prior to assigning them to actions.
Unlike connections, connection references are created inside a solution.
As you can see, during the creation process, a custom display name can be specified.
The Connector dropdown shown above contains references to all the Power Platform connectors. There are a lot of connectors, so it’s worth knowing that while SharePoint and SQL Sever are listed under their own names, Dataverse is listed as Microsoft Dataverse.
The Connections dropdown is used to assign connections to the connection reference. In the example above, I’m assigning the connection I created earlier.
Assigning Connection References to Actions in Power Automate
To assign a connection reference to an action, click the ellipsis at the right of the action header. The available connection references are displayed. If there are multiple connection references available, the one being currently used has a blue check against it.
In the example below, I’m assigning the Dataverse connection reference I created in the last section.
As I mentioned earlier, new connection references can be created from within the action, by selecting New connection reference, but they cannot be given a custom display name.
The fact that multiple actions in a flow can use the same connection reference & connection, improves efficiency and simplifies the maintenance process.
Best Practices for Connection References
- Pre-create Connection References: Create connection references before creating a flow, so they can easily be assigned to actions.
- Use Clear Naming Conventions: Name connection references clearly so their purpose is self-explanatory. A description can also be added. This will make them easier to recognise and manage, especially in environments with multiple flows and apps.
- Create in a Dedicated Solution: This is optional, but it can be very helpful when all connection references for an environment are in a dedicated solution. This allows centralized management and reusability of the connection references across all flows in the environment, avoiding duplication.
- Manage Connection References: When moving a solution, for example from Development to Test, import the solution containing the connection references before importing the flows that use them. This way, dependencies are observed and connection references can be assigned during the flow import process, ensuring a smooth deployment.
- Create New Connections: Prior to importing, create new connections in the target environment. During the import process connections in the new environment can be assigned to the connection references contained in the solution being imported. If a required connection doesn’t already exist, it can be created at the time of import.
- Remove Unnecessary Connection References: When creating, testing and importing flows, additional connection references are often inadvertently created. If they are not required, delete them to keep solutions clean and ensure actions use only the pre-defined connection references.
- Use
Service Accounts: Avoid using personal user accounts to create
connections. Instead, use service accounts or service principals to ensure
flows and apps continue functioning smoothly if users leave the
organization. This also supports better security and auditing practices.
Connection Reference Limitations and Additional Information
Some connectors, for example custom connectors or some premium services, may not support connection references. Check the connector documentation for compatibility.
If a flow or app fails due to a missing connection reference, check if the correct reference has been assigned. Ensure the connection is valid for the environment.
It’s worth noting that when viewing connection references, they always have the status of off. This is because connection references only become active for the short time they are being used by a flow or other component.
Summary
Connection references in Power Automate act as reusable links between actions and connections to data sources, simplifying the management of credentials and ensuring consistency across multiple actions. They are created within solutions to enhance control and align with Application Lifecycle Management (ALM) practices, making them essential for seamless flow imports and deployments across environments.
By using connection references, organisations can manage connections more effectively, avoid duplication, and reduce errors during solution import. Best practices include using service accounts, clear naming conventions, and ensuring connection references are imported either before or alongside flows during deployment. While not all connectors support connection references, they provide significant flexibility for automation and cross-solution use within the same environment.
- Hiredgun.tech: Using a Service Account and Service Principal with Flows
- Hiredgun.tech: Flow Execution Ownership
- Hiredgun.tech: Notes on Flow Ownership