Deploying a logic app using ARM templates/powershell

前端 未结 3 688
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 16:54

How can I Deploy a logic app that calls a SQL DB stored procedure? I\'ve tried the following action.

    \"actions\": {
            \"Execute_stored_procedur         


        
相关标签:
3条回答
  • 2021-01-15 17:26

    I've finally figured this out from @TusharJ links and I'm posting the template I've used below to configure a LogicApp that calls a SQL DB stored procedure in specific intervals.

    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]"
                }
              }
            }
          }
        }
      }
    ]
    
    0 讨论(0)
  • 2021-01-15 17:43

    Things may have changed in the API since the previous answer was given. Here is what worked for me as of 10/2016. Note: I used parameters (definitions not shown) for many of the variables:

     {
      "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'))]"
      ]
    }
    
    0 讨论(0)
  • 2021-01-15 17:47

    Here is a sample template for LogicApp ARM template + 'connections' resource
    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

    0 讨论(0)
提交回复
热议问题