WaelHamze / xrm-ci-framework

xRM CI Framework provides you with the tools automate the build and deployment of your CRM Solution. Using the framework to implement a fully automated DevOps pipeline will allow you to deploy more frequently with added consistency and quality.
MIT License
186 stars 116 forks source link

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

Open malaker opened 4 years ago

malaker commented 4 years ago

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 ?

WaelHamze commented 4 years ago

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

malaker commented 4 years ago

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 commented 3 years ago

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

malaker commented 3 years ago

Thanks ! I will check that

parvezghumra commented 3 years ago

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?

mattp65 commented 3 years ago

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.

parvezghumra commented 3 years ago

@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?

mattp65 commented 3 years ago

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.

mVermaat commented 3 years ago

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.

parvezghumra commented 3 years ago

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

parvezghumra commented 3 years ago

@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?