Azure / LogicAppsUX

https://learn.microsoft.com/azure/logic-apps
MIT License
77 stars 84 forks source link

GA (new) logic app designer fails to show connection #5311

Closed jdefesche1 closed 3 months ago

jdefesche1 commented 3 months ago

Describe the Bug with repro steps

With the new Logic App designer any action using an ApiConnection is showing an error 'Unable to initialize operation'

What type of Logic App Is this happening in?

Consumption (Portal)

Are you using new designer or old designer

New Designer

Did you refer to the TSG before filing this issue? https://aka.ms/lauxtsg

Yes

Workflow JSON

{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "When_an_item_is_modified_(V2)": {
        "recurrence": {
          "frequency": "Minute",
          "interval": "1"
        },
        "evaluatedRecurrence": {
          "frequency": "Minute",
          "interval": "1"
        },
        "splitOn": "@triggerBody()?['value']",
        "splitOnConfiguration": {
          "correlation": {
            "clientTrackingId": "@guid()"
          }
        },
        "type": "ApiConnection",
        "inputs": {
          "host": {
            "connection": {
              "name": "@parameters('$connections')['sqlTrigger']['connectionId']"
            }
          },
          "method": "get",
          "path": "/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[tblOrderEventCondor]'))}/onupdateditems",
          "queries": {
            "$top": 10
          }
        },
        "runtimeConfiguration": {
          "concurrency": {
            "runs": 10,
            "maximumWaitingRuns": 5
          }
        }
      }
    },
    "actions": {
      "Initialize_storeNumber": {
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "storeNumber",
              "type": "string",
              "value": "\"0\""
            }
          ]
        },
        "runAfter": {},
        "trackedProperties": {
          "Action": "Publish",
          "Domain": "Sales",
          "Milestone": "Started",
          "OrderId": "@{triggerBody()?['OrderId']}",
          "OrderType": "@{triggerBody()?['OrderType']}",
          "Sender": "SQL",
          "Service": "Order",
          "Version": "1.0"
        }
      },
      "Execute_stored_procedure_Get_OrderDetails": {
        "runAfter": {
          "Initialize_storeNumber": [
            "Succeeded"
          ]
        },
        "type": "ApiConnection",
        "inputs": {
          "body": {
            "OrderKey": "@{triggerBody()?['OrderId']}"
          },
          "host": {
            "connection": {
              "name": "@parameters('$connections')['sqlOrder']['connectionId']"
            }
          },
          "method": "post",
          "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/procedures/@{encodeURIComponent(encodeURIComponent('[dbo].[Get_OrderDetails]'))}"
        }
      },
      "Check_Empty_Data": {
        "type": "If",
        "expression": {
          "and": [
            {
              "not": {
                "equals": [
                  "@empty(body('Execute_stored_procedure_Get_OrderDetails')?['resultsets'])",
                  true
                ]
              }
            }
          ]
        },
        "actions": {
          "Set_storeNumber": {
            "type": "SetVariable",
            "inputs": {
              "name": "storeNumber",
              "value": "@{body('Execute_stored_procedure_Get_OrderDetails')?['resultsets']?['Table1'][0]['WinkelID']}"
            }
          },
          "Check_Web_Order": {
            "type": "If",
            "expression": {
              "or": [
                {
                  "equals": [
                    "@variables('storeNumber')",
                    "9200"
                  ]
                },
                {
                  "equals": [
                    "@variables('storeNumber')",
                    "7001"
                  ]
                },
                {
                  "equals": [
                    "@variables('storeNumber')",
                    "2199"
                  ]
                },
                {
                  "equals": [
                    "@variables('storeNumber')",
                    "0199"
                  ]
                }
              ]
            },
            "actions": {
              "Terminate_WebOrder": {
                "type": "Terminate",
                "inputs": {
                  "runStatus": "Cancelled"
                },
                "trackedProperties": {
                  "Action": "Publish",
                  "Domain": "Sales",
                  "EventText": "Web order, Processing stopped",
                  "Milestone": "Cancelled",
                  "OrderId": "@{triggerBody()?['OrderId']}",
                  "OrderType": "@{triggerBody()?['OrderType']}",
                  "Sender": "SQL",
                  "Service": "Order",
                  "Version": "1.0"
                }
              }
            },
            "else": {
              "actions": {
                "Execute_stored_procedure_Get_Articles": {
                  "runAfter": {},
                  "type": "ApiConnection",
                  "inputs": {
                    "body": {
                      "OrderKey": "@{triggerBody()?['OrderId']}"
                    },
                    "host": {
                      "connection": {
                        "name": "@parameters('$connections')['sql_Article']['connectionId']"
                      }
                    },
                    "method": "post",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/procedures/@{encodeURIComponent(encodeURIComponent('[dbo].[Get_Articles]'))}"
                  }
                },
                "Create_Merge_Result": {
                  "type": "Compose",
                  "inputs": "@concat('<Order>\n',xml(json(concat('{\"Orderdata\":',body('Execute_stored_procedure_Get_OrderDetails').ResultSets,'}'))),xml(json(concat('{\"Articles\":',body('Execute_stored_procedure_Get_Articles').ResultSets,'}'))),'\n</Order>')",
                  "runAfter": {
                    "Execute_stored_procedure_Get_Articles": [
                      "Succeeded"
                    ]
                  }
                },
                "CreateCDMOrder": {
                  "runAfter": {
                    "Create_Merge_Result": [
                      "Succeeded"
                    ]
                  },
                  "metadata": {
                    "apiDefinitionUrl": "https://invictus-hfg-dev-we-transcoapp.azurewebsites.net/swagger/docs/v1",
                    "swaggerSource": "custom"
                  },
                  "type": "Http",
                  "inputs": {
                    "authentication": {
                      "password": "123",
                      "type": "Basic",
                      "username": "Invictus"
                    },
                    "body": {
                      "Content": "@{base64(outputs('Create_Merge_Result'))}",
                      "TranscoConfig": "HFG.IP.Sales.Order.Publish.SQL.SQLOrder_to_CDMOrder.xml"
                    },
                    "method": "post",
                    "uri": "https://invictus-hfg-dev-we-transcoapp.azurewebsites.net/api/v1/transco"
                  }
                },
                "PublishCDMGenericOrder": {
                  "type": "Http",
                  "metadata": {
                    "apiDefinitionUrl": "https://invictus-hfg-dev-we-pubsubapp.azurewebsites.net/swagger/docs/v1",
                    "swaggerSource": "custom"
                  },
                  "inputs": {
                    "method": "post",
                    "uri": "https://invictus-hfg-dev-we-pubsubapp.azurewebsites.net/api/v1/publish",
                    "body": {
                      "Content": "@{body('CreateCDMOrder')?['Content']}",
                      "Context": {
                        "Action": "Publish",
                        "Domain": "Sales",
                        "OrderId": "@{triggerBody()?['OrderId']}",
                        "OrderType": "@{triggerBody()?['OrderType']}",
                        "Sender": "SQL",
                        "Service": "Order",
                        "Version": "1.0"
                      }
                    },
                    "authentication": {
                      "password": "123",
                      "type": "Basic",
                      "username": "Invictus"
                    }
                  },
                  "runAfter": {
                    "CreateCDMOrder": [
                      "Succeeded"
                    ]
                  },
                  "trackedProperties": {
                    "Action": "Publish",
                    "Domain": "Sales",
                    "EventText": "Order created/updated",
                    "Milestone": "Received",
                    "OrderId": "@{triggerBody()?['OrderId']}",
                    "OrderType": "@{triggerBody()?['OrderType']}",
                    "Sender": "SQL",
                    "Service": "Order",
                    "Version": "1.0"
                  }
                }
              }
            },
            "runAfter": {
              "Set_storeNumber": [
                "Succeeded"
              ]
            }
          }
        },
        "else": {
          "actions": {
            "Terminate": {
              "type": "Terminate",
              "inputs": {
                "runStatus": "Cancelled"
              },
              "trackedProperties": {
                "Action": "Publish",
                "Domain": "Sales",
                "EventText": "No OrderDetails Returned",
                "Milestone": "Cancelled",
                "OrderId": "@{triggerBody()?['OrderId']}",
                "OrderType": "@{triggerBody()?['OrderType']}",
                "Sender": "SQL",
                "Service": "Order",
                "Version": "1.0"
              }
            }
          }
        },
        "runAfter": {
          "Execute_stored_procedure_Get_OrderDetails": [
            "Succeeded"
          ]
        }
      }
    },
    "outputs": {},
    "parameters": {
      "$connections": {
        "type": "Object",
        "defaultValue": {}
      }
    }
  },
  "parameters": {
    "$connections": {
      "value": {
        "sqlTrigger": {
          "id": "subscriptions/1d4740af-e85c-41b4-9b76-7b65edcd6abd/providers/Microsoft.Web/locations/westeurope/managedApis/sql",
          "connectionId": "/subscriptions/1d4740af-e85c-41b4-9b76-7b65edcd6abd/resourceGroups/hfg-dev-we-sales-order-1.0/providers/Microsoft.Web/connections/hfg-dev-we-rcv-sales-order-publish-1.0-sql-con-sql-trigger",
          "connectionName": "hfg-dev-we-rcv-sales-order-publish-1.1-sql-con-sql-trigger"
        },
        "sqlOrder": {
          "id": "subscriptions/1d4740af-e85c-41b4-9b76-7b65edcd6abd/providers/Microsoft.Web/locations/westeurope/managedApis/sql",
          "connectionId": "/subscriptions/1d4740af-e85c-41b4-9b76-7b65edcd6abd/resourceGroups/hfg-dev-we-sales-order-1.0/providers/Microsoft.Web/connections/hfg-dev-we-rcv-sales-order-publish-1.0-sql-con-sql-Order",
          "connectionName": "hfg-dev-we-rcv-sales-order-publish-1.1-sql-con-sql-Order"
        },
        "sql_Article": {
          "id": "subscriptions/1d4740af-e85c-41b4-9b76-7b65edcd6abd/providers/Microsoft.Web/locations/westeurope/managedApis/sql",
          "connectionId": "/subscriptions/1d4740af-e85c-41b4-9b76-7b65edcd6abd/resourceGroups/hfg-dev-we-sales-order-1.0/providers/Microsoft.Web/connections/hfg-dev-we-rcv-sales-order-publish-1.0-sql-con-sql-Article",
          "connectionName": "hfg-dev-we-rcv-sales-order-publish-1.1-sql-con-sql-Article"
        }
      }
    }
  }
}

Screenshots or Videos

azure_error

Browser

Firefox

Additional context

If I create a similar logic app by hand in the portal it works (no errors), but I can't find any relevant differences in the code views.

hartra344 commented 3 months ago

@rllyy97 can you take a look?

rllyy97 commented 3 months ago

Hi @jdefesche1, if you recreated another workflow with the same code view, I would guess it might be something related to how you have your connections defined. Could you send your connections json to me at rileyevans@microsoft.com and I'll take a look? Feel free to obfuscate anything that might be sensitive, but leave any parameter references in place please, I think those could be causing this

jdefesche1 commented 3 months ago

Hi @rllyy97,

I sent you the code. Meanwhile I have been investigating myself as well. I think I found the problem. In our arm template we have a variable called sqlConnectionManagedApiId

"sqlConnectionManagedApiId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('location'), '/managedApis/sql')]",

We use this variable to point to the correct api id. For our troubling logic apps I noticed that the first slash in front of subscriptions was missing. After adding that, the problem went away.

rllyy97 commented 3 months ago

@jdefesche1 Glad you were able to get it fixed! I'm going to close the issue but if you have anything else to add feel free to comment again and we can reopen if needed