Hi!
My question
I cannot find any way to programmatically create a Connection.
Any ideas on how to accomplish this, even if complicated, is of interest to me.
The background
In my automatic test pipeline setup I currently copy a template environment to a test environment to be able to test solution import followed by the execution of automatic tests. When I copy an environment the target environment does not lose its already existing Connections, but when I execute an environment reset instead, all existing Connections are lost. I would prefer that my pipeline would use a reset operation instead of a copy operation, but that requires me to create a Dataverse Connection programmatically after the reset, in order to connect it to the Connection Reference included in the solution package being imported. Otherwise the cloud flows in the solution cannot be verified by the automatic tests.
Best regards,
Henrik Svensson
I am using the Power Automate Management action "Create Connection" (placed in another environment) to create a Microsoft Dataverse Connection after my test environment has been reset. That in itself is not enough to make my app user able to assign that Connection to a Connection Reference (it results in an error). I have to programmatically share the Connection to the App User first (even though both the Connection and the App User use the same service principal).
Sharing a Connection programmatically is possible using the Edit Connection Role Assignment operation of the Power Apps for Makers Connector. Thus, these are the steps that did the trick:
Worth mentioning is that the resulting "Connection Name" from the "Create Connection" action is the Connection Id. And the Connector Name (to be set on the Edit Connection Role Assignment action) is not "Microsoft Dataverse", but corresponds to what is displayed as part of the URL when you open the details view of your connection.
Another thing to be aware of is that the "properties/principal/id" value is the Object Id of your service principal (not the Application Id), i.e., this property, on the properties page of your service principal enterprise application in the Azure portal:
Seems to be image URL in the post is broken. Hence, I'm not understanding how to provide the "Connection Name" and "Connector Name" on the Edit Connection Role Assignment action.
Please find attached image for your reference.
When I try to run below action I'm facing an error as below.
Kindly help me out to Share a Connection programmatically.
Thanks,
Jeeva
I made it work!
I am using the Power Automate Management action "Create Connection" (placed in another environment) to create a Microsoft Dataverse Connection after my test environment has been reset. That in itself is not enough to make my app user able to assign that Connection to a Connection Reference (it results in an error). I have to programmatically share the Connection to the App User first (even though both the Connection and the App User use the same service principal).
Sharing a Connection programmatically is possible using the Edit Connection Role Assignment operation of the Power Apps for Makers Connector. Thus, these are the steps that did the trick:
Worth mentioning is that the resulting "Connection Name" from the "Create Connection" action is the Connection Id. And the Connector Name (to be set on the Edit Connection Role Assignment action) is not "Microsoft Dataverse", but corresponds to what is displayed as part of the URL when you open the details view of your connection.
Another thing to be aware of is that the "properties/principal/id" value is the Object Id of your service principal (not the Application Id), i.e., this property, on the properties page of your service principal enterprise application in the Azure portal:
Thanks for pointing me in the right direction!
Hopefully the information above can save someone else some time, because this took me several hours to figure out.
Thank you for the suggestions, @ivan_apps. I'll look into this and report back with the results.
Best regards,
Henrik Svensson
Alternatively, this may work -
Perhaps you can trigger the opening of the app to create the connections?
Then you can set the environment to bypass the API consent for your test -
In theory I would imagine that should auto-create all the connections your app needs.
stampcoin
15
ankit_singhal
11
Super User 2025 Season 1
mmbr1606
9
Super User 2025 Season 1