When I create Logic App with a deployment template, the api connection resource is deleted

David Hautbois 0 Reputation points
2023-11-05T22:07:16.1666667+00:00

Hello

When I create a logic app with this template :

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "workflows_dhalogicapp_name": {
            "defaultValue": "${logicapp_name}",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('workflows_dhalogicapp_name')]",
            "location": "westeurope",
            "identity": {
                "type": "SystemAssigned"
            },
            "properties": {
                "state": "Enabled",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        }
                    },
                    "triggers": ${reccurences},
                    "actions": {
                        "Deallocate_virtual_machine": {
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['azurevm']['connectionId']"
                                    }
                                },
                                "method": "post",
                                "path": "/subscriptions/@{encodeURIComponent('6b750f26-85f7-4089-886e-c8453a8cd96c')}/resourcegroups/@{encodeURIComponent('dha-test')}/providers/Microsoft.Compute/virtualMachines/@{encodeURIComponent('dhavm')}/deallocate",
                                "queries": {
                                    "api-version": "2019-12-01"
                                }
                            },
                            "runAfter": {},
                            "type": "ApiConnection"
                        }
                    }
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "azurevm": {
                                "connectionId": "${api_connection_id}",
                                "connectionName": "example-connection",
                                "id": "/subscriptions/6b750f26-85f7-4089-886e-c8453a8cd96c/providers/Microsoft.Web/locations/westeurope/managedApis/azurevm"
                            }
                        }
                    }
                }
            }
        }
    ]
}

The existing api connection resource is deleted.

In don't understand...

Thanks

David.

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,996 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 24,111 Reputation points
    2023-11-09T15:42:08.79+00:00

    @David Hautbois Thanks for the update, The issue you’re experiencing might be due to the deployment mode of your ARM template. If you’re using the “Complete” deployment mode, it will delete resources that exist in the resource group but are not specified in the template. This could be why your existing API connection resource is being deleted.

    To resolve this, you can change the deployment mode to “Incremental”. This mode will only add or update the resources specified in the template, without deleting any existing resources.

    Here’s an example of how you can deploy the template with Azure CLI using the “Incremental” mode:

    az deployment group create --resource-group <resource-group-name> --template-file <template-file-path> --mode Incremental

    Replace <resource-group-name> with the name of your resource group, and <template-file-path> with the path to your template file.

    If you’re deploying the template through the Azure portal, you can select the “Incremental” mode in the “Custom deployment” blade.

    Please try this and let me know if it helps.

    1 person found this answer helpful.