3
votes

I have created one logic app, now I want to copy the same logic to another resource group that I can use for the testing environment.

Can some one help me out with either Azure CLI command or any direct option in the Azure portal itself to copy the logic app from one resource group to another resource group.

I checked in the Azure portal, I can see only the "Move" option, when I use that it is just move my logic app from resource group 1 to resource group 2. But my requirement is it should present in both the resource groups .

Thanks in advance.

Regards, Manikanta

4

4 Answers

4
votes

From Azure portal, you can easily copy your logic app using the Clone button

enter image description here

4
votes

You could download the logic app and connections as an ARM template using Logic app VS tools, with this way it contains all connections you set.

Then you could edit it , if you use Visual Studio, just replace the LogicApp.json with the one you downloaded.

If your selected connectors need input from you, a PowerShell window opens in the background and prompts for any necessary passwords or secret keys. After you enter this information, deployment continues.

Also you could deploy the template with Azure Cli.

1
votes

This might make a little mess with connections, but I found this approach working faster for large LA's than manually recreating the same LA in a new resource group:

  1. Open the logic app (LA01), click the clone button and save it with a different name (LA02) in the same resource group.
  2. Open LA02 and near the resource group click change. enter image description here Choose new resource group to which you want to move it. You can also choose related resources if needed, but you probably want to make a copy of them too. Please make sure that you understand that all tools and scripts associated with moved resources will not work until you update them to use new resource IDs. This operation might take some time.
  3. Optional. You might want to use the same name (LA01) as in previous resource group. Sadly I think you can not rename items in Azure, so perform the step #1 again to make a copy with LA01 name and remove LA02 from new resource group.
  4. After those steps open copied LA and recreate all the connections.
0
votes

I have also found another pretty neat way how to update already existing LA in other resource groups. It might look a little messy, but when you do it for several times, you can do it much way faster than just always cloning LA. When you open LA and click on Code view you need to notice that each LA structure is like in an example below. You can take all code in LA1 (resource group 1) from top till outputs and copy paste it to new LA2 (resource group 2), but some changes needs to be done in LA2 the first time you do this:

  • SomeActions - this will be copy pasted as is
  • $connections - this must be left as is, it's a pointer to LA connection definition
  • OtherParameters - this is your parameters that you will be passing to LA, so usually for different resource group you use different parameters, so keep this in mind and change accordingly if this is the case
  • SomeTrigger - Usually you should leave it as it was defined in LA2.
  • SomeConnection - the most important part is to make sure that in both LA you are using the same connection reference. If not the case, then retrieve the connection reference name from SomeActions part, and update the SomeConnection, but leave connectionId and connectionName as it was defined in LA2, so only the connection name matches between both LA.

Next time you want to do an update you just take the code, and copy everything from top till outputs.

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
           ...SomeActions
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            },
            "OtherParameters": {
                "defaultValue": "SomeValue",
                "type": "String"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {
                       ...SomeTrigger
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "SomeConnection": {
                    "connectionId": "SomeId",
                    "connectionName": "SomeName",
                    "id": "SomeId"
                }
            }
        }
    }
}