jeffhollan / LogicAppTemplateCreator

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

Generation for custom connector generates hard coded value #52

Open mikaelsand opened 5 years ago

mikaelsand commented 5 years ago

I tried to fix this in the code, but I lack the skillz. When creating a template with a custom connector. The ARM template contains a value for the connector. This value would benefit from being parameterized. Example:

"id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('MyValue-CustomConnector-ResourceGroup'),'/providers/Microsoft.Web/customApis/MyValue-CustomConnector-SOAPPassthru-DEV')]"

would be great if it looked like this:

"id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('MyValue-CustomConnector-ResourceGroup'),'/providers/Microsoft.Web/customApis/', parameters('MyValue-CustomConnector-Connectorname)]",
gethari commented 5 years ago

I will try to fix this

MLogdberg commented 4 years ago

This should be the case, we even have a test for exactly this scenario. You are talking about the CustomConnector connection inside the Logic App ARM Template right?

According t my test class CustomConnectorTest and it's tests it will be generated as follows:

Following is crapy formated but the important part from the top snippet is the "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('LDAPAdapter-ResourceGroup'),'/providers/Microsoft.Web/customApis/',parameters('LDAPAdapter_name'),'')]"

and the important part from the bottom snippet is: "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('LDAPAdapter-ResourceGroup'),'/providers/Microsoft.Web/customApis/',parameters('LDAPAdapter_name'),'')]"

$connections part: "parameters": { "$connections": { "value": { "LDAPAdapter": { "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('LDAPAdapter-ResourceGroup'),'/providers/Microsoft.Web/customApis/',parameters('LDAPAdapter_name'),'')]", "connectionId": "[resourceId('Microsoft.Web/connections', parameters('LDAPAdapter_name'))]", "connectionName": "[parameters('LDAPAdapter_name')]" }, "azureblob": { "id": "[concat('/subscriptions/',subscription().subscriptionId,'/providers/Microsoft.Web/locations/',parameters('logicAppLocation'),'/managedApis/azureblob')]", "connectionId": "[resourceId('Microsoft.Web/connections', parameters('azureblob_name'))]", "connectionName": "[parameters('azureblob_name')]" } } } },

And the Connection resource will look like:

{ "type": "Microsoft.Web/connections", "apiVersion": "2016-06-01", "location": "[parameters('logicAppLocation')]", "name": "[parameters('LDAPAdapter_name')]", "properties": { "api": { "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('LDAPAdapter-ResourceGroup'),'/providers/Microsoft.Web/customApis/',parameters('LDAPAdapter_name'),'')]" }, "displayName": "[parameters('LDAPAdapter_displayName')]", "parameterValues": { "authType": "[parameters('LDAPAdapter_authType')]", "gateway": { "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',parameters('LDAPAdapter_gatewayresourcegroup'),'/providers/Microsoft.Web/connectionGateways/',parameters('LDAPAdapter_gatewayname'))]" } } } }

Both of them has the id in a parameter as you reported, can you verify that you get this also or if we have something that makes the generation differently.

mikaelsand commented 4 years ago

@MLogdberg Are you talking to me? If so, yes the thing I posted really happened. What kind of information do you feel you need? I would be VERY happy to get this thing out of the "needs to be handled manually step". Perhaps it is because I am using the SOAP passthru?

MLogdberg commented 4 years ago

@mikaelsand okey, then I'll take a look at it.

erkoolio commented 3 years ago

Hey!

When deploying arm template to a different subscription there maybe a need to look at resources from different subscriptions, is it possible to parametrize subscription id in logic app template when using GetARMTemplate script? I have not checked if the data is available, but when deploying with hard coded value the deployment is successsful, so I'm guessing the data can be seen when creating template with the script.

MLogdberg commented 3 years ago

Yes it's possible to set subscriptionID as parameter as you mention now it's assuming it's in the same subscription. It will be some places it should be added. I'll take a look and come back to you

erkoolio commented 3 years ago

I added the subscriptionId as parameter, I'll do a pull request after I have merged the latest changes to my version.

erkoolio commented 3 years ago

I have the yesterdays latest version and I have parametrized subscriptionid, I did not do a pull request, I just edited master branch (I know, should have used pull request). I have also adjusted the tests to handle the subscription parametrization. (Meaning subscription.subscriptionid() => parameter('somename')

Should I still use pull request or how should I go forward with this?