xrm-ci-framework icon indicating copy to clipboard operation
xrm-ci-framework copied to clipboard

Do you know how programmatically import solution with passing connection references ?

Open malaker opened this issue 3 years ago • 11 comments

Hi I cannot find in current xrm-ci-framework way of configuring connection references within import request. Do you know guys how to do this ?

malaker avatar Oct 08 '20 16:10 malaker

You mean creating this entity? https://docs.microsoft.com/en-gb/powerapps/developer/common-data-service/reference/entities/connectionreference

WaelHamze avatar Oct 11 '20 12:10 WaelHamze

maybe...

When you have in solution connection references then during import the solution in other environment in new UI during importing user is asked for providing new connections. I am wondering if those connections can be provided somehow programmatically

malaker avatar Oct 12 '20 18:10 malaker

I don't think this is supported yet, we've been asking MS for a while now on this and keep getting "its not ready yet" - hoping that the functionality will be available in the next couple of months. I had a conversation with someone on Twitter who pointed me at their import powershell script that was used to remap connection references. This might help you out.

https://gist.github.com/devkeydet/f31554566b2e53ddd8e7e1db4af555a6

this relies on you having the connections set up in the target environment but it should help reduce your effort.

maybe...

When you have in solution connection references then during import the solution in other environment in new UI during importing user is asked for providing new connections. I am wondering if those connections can be provided somehow programmatically

don-matese avatar Jan 13 '21 21:01 don-matese

Thanks ! I will check that

malaker avatar Jan 14 '21 09:01 malaker

I found this blog post earlier which basically explains in plain English how to manually perform the steps performed by the PowerShell script referenced above by @don-matese.

Does anyone know where Power Automate Connections are stored? Are they held within an entity in Dataverse that is accessible either via the user interface or the API/SDK?

parvezghumra avatar Jan 19 '21 14:01 parvezghumra

That PowerShell script actually shows updating the entity. It is in CDS and the schema name is connectionreference. It is a newer entity and I have yet to play with updating it myself yet. I had gone the path previously of modifying the underlying YAML which got ugly really quickly.

mattp65 avatar Jan 19 '21 15:01 mattp65

@mattp65 I know the records to update are in the connectionreference entity. I was referring to the entity from which we can identify the connection id to use. The PowerShell script is expecting this value to be passed in. I was hoping I would be able to retrieve this dynamically from the environment at runtime?

parvezghumra avatar Jan 19 '21 16:01 parvezghumra

Sorry, misunderstood. The setup they have is really goofy. I haven't been able to find a good way to track this through to find the GUID at run time. Best I have come up with is to setup a dummy flow that uses each connection type and make sure that is configured properly in the target env and then use that to figure out the GUIDs. Where it gets tough is that the connections, when stored, are user specific. So there can be multiple connections for the same system and no easy way to determine which one to choose.

mattp65 avatar Jan 19 '21 16:01 mattp65

You can use the PowerApps Powershell module to find the connections. It has a 'Get-PowerAppConnection' function to get the connections.

This returns all connections to all environments you have access to. You can filter it by adding the '-EnvironmentName' parameter. This environment is GUID, you can find these with the 'Get-PowerAppEnvironment' function. Problem is that there is no direct connection between the powerapp and CDS organization. The only connection is the display name. It works but I'm not really happy with using a display name. At least it is unique, as it will put the uniquename between brackets if it's different from the uniquename.

When you figure out the environment, next you need to do is get the correct connection from all of the different connections. This can be easy, but also impossible. The connector has a name (for CDS it's 'shared_commondataserviceforapps'). This can be matched with the connectorid attribute of the connection reference. This works, unless you have multiple connections of the same type. Then I don't know any way to select the correct connection.

All in all I think the most effective and cost efficient way is to simply create a simple json file where you specify the connection references and the connectionids per environment. The connectionid is in the URL when you open a connection. You will need to create the connections manually anyway, might aswell dump the connectionid in a JSON and be done with it.

mVermaat avatar Jan 29 '21 15:01 mVermaat

Thanks for the insight @mVermaat. I'll give it a try :)

parvezghumra avatar Jan 30 '21 16:01 parvezghumra

@WaelHamze I noticed this interesting commit with the some Connection Reference management code in it :) https://github.com/WaelHamze/xrm-ci-framework/commit/a6c12b831fe42336e05b46a7819c8a8f620b3d90

Does this mean a pipeline task is in the making/available?

parvezghumra avatar Feb 11 '21 15:02 parvezghumra