jeffhollan / LogicAppTemplateCreator

Script to convert Logic Apps into templates for deployment
MIT License
144 stars 74 forks source link

Common Data Service actions keep hardcoded environment #99

Closed Costin-hcl closed 3 years ago

Costin-hcl commented 3 years ago

When exporting a Logic App with a CDS action, the action keeps its "path" property hardcoded:

     "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('orgdXXXXXX.crm4'))}/tables/@{encodeURIComponent(encodeURIComponent('cdm_table'))}/items/@{encodeURIComponent(encodeURIComponent(triggerBody()?['empNumber']))}"

This is very hard to de-hardcode especially is a workflow expression is used - we need to add an apostrophe ARM parameter and concatenate to the formula.

MLogdberg commented 3 years ago

Thanks for reporting this, it should be solved by PR #100, please take a look and test it out.

Costin-hcl commented 3 years ago

Later edit - checked the latest version and it does work as expected now. Thanks @MLogdberg

=== @MLogdberg - I do see some change but the path is still not added as a parameter. Here is what I got from a CDS action:

"Get_Contact_Name": { "runAfter": { "Condition": [ "Succeeded" ] }, "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['commondataservice']['connectionId']" } }, "method": "get", "path": "/v2/datasets/oXXXXXXXXXXXXXX.crm/tables/contacts/items/@{variables('contactId')}" } },

The path property still has /v2/datasets/oXXXXXXXXXXXXXX.crm/ hard-coded. I was using the binary though, did a Update-Module LogicAppTemplate. How can I check the version does it have a command line argument?

MLogdberg commented 3 years ago

Looks like it might be missing this type of action I'll take a look

MLogdberg commented 3 years ago

Hi,

I've tried almost all actions, here is a sample of Get Record: "Get_record": { "runAfter": { "Create_a_new_record": [ "Succeeded" ] }, "type": "ApiConnection", "inputs": { "host": { "connection": { "name": "@parameters('$connections')['commondataservice_1']['connectionId']" } }, "method": "get", "path": "[concat('/v2/datasets/@{encodeURIComponent(encodeURIComponent(', parameters('__apostrophe'), parameters('Get_record-environment'), parameters('__apostrophe'), '))}/tables/@{encodeURIComponent(encodeURIComponent(''cdmtmp_accountcontacts''))}/items/@{encodeURIComponent(encodeURIComponent(variables(''myId'')))}')]" } }, A difference that I'm seeing is the @{encodedUri part that is missing in your sample, have you edited it yourself? Since if I use the Logic App Designer I get that part added automatically, and as I look in to the code I'm assuming that is coming. any preference from your side that this shoudl work anyway? (I guess yes but just want to know =) )

Here is my version running: ` PS C:\temp\ARMTemplateGenerators> Get-Module LogicAppTemplate ModuleType Version Name ExportedCommands


Binary 0.1.4.0 LogicAppTemplate {Get-EmptyParameterTemplate, Get-CustomConnectorTemplate, Get-IntegrationAccountSchemaTemplate, Get-IntegrationAccountMapTempla...

`

Costin-hcl commented 3 years ago

@MLogdberg - I did say it was working with the new version - later edit. Initially, I tried Update-Module and this probably didn't update. So then I just got the latest version from GitHub, built the DLL, imported it from the local debug folder and tested. The changes work well now, they just need to be published.

Many thanks!

MLogdberg commented 3 years ago

Ahh sorry my bad for bad reading, awesome it works! 👍 Closing this issue now. And I'm using the latest from PowerShellGallery, so try updated it now.