2

如何部署调用 SQL DB 存储过程的逻辑应用?我尝试了以下操作。

    "actions": {
            "Execute_stored_procedure": {
              "conditions": [ ],
              "inputs": {
                "body": null,
                "host": {
                  "api": {
                    "runtimeUrl": "https://logic-apis-northcentralus.azure-apim.net/apim/sql"
                  },
                  "connection": {
                    "name": "<sql connection string>"
                  }
                },
                "method": "post",
                "path": "/datasets/default/procedures/@{encodeURIComponent(encodeURIComponent(string('<stored-procedure-name>')))}"
              },
              "type": "apiconnection"
            }
          }

当我部署此模板时,逻辑应用程序已创建,但它引发错误或 SQL 连接操作未显示在设计视图上。我在这里做错了什么?arm目前是否支持调用SQL Stored Proc的Logic App?

4

3 回答 3

3

这是 LogicApp ARM 模板 +“连接”资源的示例模板
https://blogs.msdn.microsoft.com/logicapps/2016/02/23/deploying-in-the-logic-apps-preview-refresh/
https: //github.com/jeffhollan/logicapps-deployments/blob/master/ftp_to_blob.json

于 2016-05-16T00:40:49.360 回答
2

自从给出上一个答案以来,API 中的事情可能已经发生了变化。这是截至 2016 年 10 月对我有用的方法。注意:我为许多变量使用了参数(未显示定义):

 {
  "type": "Microsoft.Web/connections",
  "apiVersion": "2015-08-01-preview",
  "location": "[parameters('location')]",
  "name": "[variables('sql_conn_name')]",
  "properties": {
    "api": {
      "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]"
    },
    "displayName": "sql_connection",
    "parameterValues": {
      "server": "[concat(variables('dbserver_unique_name'), '.database.windows.net')]",
      "database": "[parameters('databases_name')]",
      "authType": "windows",
      "username": "[parameters('databases_admin_user')]",
      "password": "[parameters('databases_admin_password')]"
    }
  }
}, 
{
  "type": "Microsoft.Logic/workflows",
  "name": "[variables('logic_app_name')]",
  "apiVersion": "2016-06-01",
  "location": "[parameters('location')]",
  "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": {
        "Recurrence": {
          "recurrence": {
            "frequency": "Hour",
            "interval": 1
          },
          "type": "Recurrence"
        }
      },
      "actions": {
        "Execute_stored_procedure": {
          "runAfter": { },
          "type": "ApiConnection",
          "inputs": {
            "body": {
              "timeoffset": "-4"
            },
            "host": {
              "api": {
                "runtimeUrl": "[concat('https://logic-apis-', parameters('location'), '.azure-apim.net/apim/sql')]"
              },
              "connection": {
                "name": "@parameters('$connections')['sql']['connectionId']"
              }
            },
            "method": "post",
            "path": "/datasets/default/procedures/@{encodeURIComponent(encodeURIComponent('[dbo].[usp_UpdateHourlyOos]'))}"
          }
        }
      },
      "outputs": { }
    },
    "parameters": {
      "$connections": {
        "value": {
          "sql": {
            "connectionId": "[concat(subscription().id, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Web/connections/', variables('sql_conn_name'))]",
            "connectionName": "[variables('sql_conn_name')]",
            "id": "[concat(subscription().id,'/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]"
          }
        }
      }
    }
  },
  "resources": [ ],
  "dependsOn": [
    "[resourceId('Microsoft.Web/connections', variables('sql_conn_name'))]"
  ]
}
于 2016-10-13T16:27:30.090 回答
2

我终于从@TusharJ 链接中弄清楚了这一点,并且我发布了我在下面使用的模板来配置一个以特定间隔调用 SQL DB 存储过程的 LogicApp。

resources:
[
  {
    "type": "Microsoft.Web/connections",
    "apiVersion": "2015-08-01-preview",
    "location": "[resourceGroup().location]",
    "name": "sqlconnector",
    "properties": {
      "api": {
        "id": "[concat('subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]"
      },
      "displayName": "sqlconnector",
      "parameterValues": {
        "sqlConnectionString": "<sql db connection string>"
      }
    }
  },
  {
    "type": "Microsoft.Logic/workflows",
    "apiVersion": "2015-08-01-preview",
    "name": "[parameters('logicAppName')]",
    "location": "[resourceGroup().location]",
    "tags": {
      "displayName": "LogicApp"
    },
    "properties": {
      "sku": {
        "name": "[parameters('workflowSkuName')]",
        "plan": {
          "id": "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('svcPlanName'))]"
        }
      },
      "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2015-08-01-preview/workflowdefinition.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
          "$connections": {
            "defaultValue": { },
            "type": "Object"
          }
        },
        "triggers": {
          "recurrence": {
            "type": "recurrence",
            "recurrence": {
              "frequency": "Hour",
              "interval": 1
            }
          }
        },
        "actions": {
          "Execute_stored_procedure": {
            "conditions": [ ],
            "inputs": {
              "body": null,
              "host": {
                "api": {
                  "runtimeUrl": "[concat('https://logic-apis-', resourceGroup().location, '.azure-apim.net/apim/sql')]"
                },
                "connection": {
                  "name": "@parameters('$connections')['sql']['connectionId']"
                }
              },
              "method": "post",
              "path": "/datasets/default/procedures/@{encodeURIComponent(encodeURIComponent(string('[dbo].[<Stored Proc Name>]')))}"
            },
            "type": "apiconnection"
          }
        },
        "outputs": { }
      },
      "parameters": {
        "$connections": {
          "value": {
            "sql": {
              "connectionId": "[resourceId('Microsoft.Web/connections', 'sqlconnector')]",
              "connectionName": "sqlconnector",
              "id": "[reference(concat('Microsoft.Web/connections/', 'sqlconnector'), '2015-08-01-preview').api.id]"
            }
          }
        }
      }
    }
  }
]
于 2016-05-18T09:41:36.467 回答