将消费逻辑应用程序迁移到标准

Migrate Consumption Logic App to Standard

这是 this question

的后续

该答案涵盖了一个基本案例,但如果工作流包括数据库访问则不起作用,至少这是我发现的 SQL 服务器。此外,标准中提供的唯一 SQL 服务器操作是执行查询,这是对消费

的重大改进

到目前为止,我还没有找到任何不手动重新编码工作流程的方法来实现此迁移 - 既费时又冒险,需要进行大量回归测试

就像我在另一个线程中提到的那样,它确实有效,但需要做的更改很少。

Further, the only SQL Server operation offered in Standard is Execute Query, which is a significant dis-improvement from Consumption.

Sql 服务器在内置连接器中不可用,但在 Azure 连接器中可用。这是供您参考的屏幕截图:

That answer covers a basic case, but does not work if the workflow includes DB access, at least that is what I found, for SQL Server.

一种解决方法是您需要在 Sql 连接器的代码视图中进行少量更改,以使连接器正常工作。考虑下面的代码视图。

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Get_rows_(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sql_1']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[STATION]'))}/items"
                },
                "runAfter": {},
                "type": "ApiConnection"
            },
            "Get_tables_(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['sql_1']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables"
                },
                "runAfter": {
                    "Get_rows_(V2)": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "sql_1": {
                    "connectionId": "/subscriptions/<Your suscription>/resourceGroups/<Your resource group>/providers/Microsoft.Web/connections/sql-4",
                    "connectionName": "sql-4",
                    "id": "/subscriptions/<Your suscription>/providers/Microsoft.Web/locations/northcentralus/managedApis/sql"
                }
            }
        }
    }
}

以下是您需要在逻辑中设置的更改。

  • 删除参数{ } 即..

    "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
    
    "parameters": {
        "$connections": {
            "value": {
                "sql_1": {
                    "connectionId": "/subscriptions/<Your suscription>/resourceGroups/<Your resource group>/providers/Microsoft.Web/connections/sql-4",
                    "connectionName": "sql-4",
                    "id": "/subscriptions/<Your suscription>/providers/Microsoft.Web/locations/northcentralus/managedApis/sql"
                }
            }
        }
    }
    
  • 将 Get_rows_(V2) 和 Get_tables_(V2) 中的 "connection": {"name": "@parameters('$connections')['sql_1']['connectionId']"} 替换为 "connection": {"referenceName": "sql"}

  • 在最后添加您的工作流程类型,即 "kind": "Stateful"

更改后下面是我的逻辑应用程序的代码视图

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Get_rows_(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "referenceName": "sql"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables/@{encodeURIComponent(encodeURIComponent('[dbo].[STATION]'))}/items"
                },
                "runAfter": {},
                "type": "ApiConnection"
            },
            "Get_tables_(V2)": {
                "inputs": {
                    "host": {
                        "connection": {
                            "referenceName": "sql"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))},@{encodeURIComponent(encodeURIComponent('default'))}/tables"
                },
                "runAfter": {
                    "Get_rows_(V2)": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "kind": "Stateful"
}