16

私のファイルで

LogicApp.parameters.json

MyFirstNewParameter という追加のパラメーターを宣言しました

以下の完全なファイルの内容

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "logicAppName": {
      "value": "MyFirstLogicAppOne"
    },
    "servicebus_1_connectionString": {
      "value": "Endpoint=sb://notForYouToSee"
    },
    "MyFirstNewParameter": {
      "value": "abc123"
    }
  }
}

LogicApp.json ファイルに、MyFirstNewParameter の「宣言」を追加しました。

の中に

"パラメーター": {}

領域 (下の 4 行目はそのセクションの開始場所です)

また、パラメーター値を読み取って応答で送り返す単純な応答も追加しました。(すべてのものの「Read_And_Use_Parameter_Value_Simple_Response」という名前)

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "logicAppName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "metadata": {
        "description": "Name of the Logic App."
      }
    },
    "logicAppLocation": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "allowedValues": [
        "eastasia",
        "southeastasia",
        "centralus",
        "eastus",
        "eastus2",
        "westus",
        "northcentralus",
        "southcentralus",
        "northeurope",
        "westeurope",
        "japanwest",
        "japaneast",
        "brazilsouth",
        "australiaeast",
        "australiasoutheast",
        "southindia",
        "centralindia",
        "westindia",
        "canadacentral",
        "canadaeast",
        "uksouth",
        "ukwest",
        "westcentralus",
        "westus2",
        "[resourceGroup().location]"
      ],
      "metadata": {
        "description": "Location of the Logic App."
      }
    },
    "MyFirstNewParameter": {
      "type": "string",
      "metadata": {
        "description": "Name of the MyFirstNewParameter."
      },
      "defaultValue": "My1NewParameterDefaultValue"
    }
  },
  "variables": {},
  "resources": [
    {
      "name": "[parameters('logicAppName')]",
      "type": "Microsoft.Logic/workflows",
      "location": "[parameters('logicAppLocation')]",
      "tags": {
        "displayName": "LogicApp"
      },
      "apiVersion": "2016-06-01",
      "properties": {
        "definition": {
          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
          "actions": {
            "Read_And_Use_Parameter_Value_Simple_Response": {
              "type": "Response",
              "inputs": {
                "statusCode": 200,
                "body": "The parameter value is ***@{parameters('MyFirstNewParameter')}***"
              },
              "runAfter": {}
            }
          },
          "parameters": {},
          "triggers": {
            "manual": {
              "type": "Request",
              "kind": "Http",
              "inputs": {
                "schema": {}
              }
            }
          },
          "contentVersion": "1.0.0.0",
          "outputs": {}
        },
        "parameters": {}
      }
    }
  ],
  "outputs": {}
}

ここに画像の説明を入力

リクエストを送信すると、クライアントで以下を取得します。

{
    "error": {
        "code": "NoResponse",
        "message": "The server did not received a response from an upstream server. Request tracking id '000000000000000000000'."
    }
}

ポータルを確認すると、次のエラーが生成されます。

テンプレートが無効です。アクション 'Read_And_Use_Parameter_Value_Simple_Response' 入力のテンプレート言語式を行 '1' 列 '1232' で処理できません: 'ワークフロー パラメーター 'MyFirstNewParameter' が見つかりません。

何をするって?

ロジック アプリの LogicApp.parameters.json で定義されたパラメーターを "読み取る" にはどうすればよいですか?

関心のある URL

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#parameters

正しく動作するコードを追加

受け入れられた回答は、パラメーターのセットにあいまいさがあることを示しています。

これは、あいまいでない名前の修正された実用的な回答です。

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "logicAppName": {
      "value": "MylogicAppName"
    },
    "MyFirstNewArmParameter": {
      "value": "ValueIWantToSeeShowUp"
    }
  }
}

   {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "logicAppName": {
        "type": "string",
        "minLength": 1,
        "maxLength": 80,
        "metadata": {
          "description": "Name of the Logic App."
        }
      },
      "logicAppLocation": {
        "type": "string",
        "defaultValue": "[resourceGroup().location]",
        "allowedValues": [
          "eastasia",
          "southeastasia",
          "centralus",
          "eastus",
          "eastus2",
          "westus",
          "northcentralus",
          "southcentralus",
          "northeurope",
          "westeurope",
          "japanwest",
          "japaneast",
          "brazilsouth",
          "australiaeast",
          "australiasoutheast",
          "southindia",
          "centralindia",
          "westindia",
          "canadacentral",
          "canadaeast",
          "uksouth",
          "ukwest",
          "westcentralus",
          "westus2",
          "[resourceGroup().location]"
        ],
        "metadata": {
          "description": "Location of the Logic App."
        }
      },
      "MyFirstNewArmParameter": {
        "type": "string",
        "metadata": {
          "description": "Name of the MyFirstNewArmParameter."
        },
        "defaultValue": "My1NewArmParameterDefaultValue"
      }
    },
    "variables": {

    },
    "resources": [{
        "name": "[parameters('logicAppName')]",
        "type": "Microsoft.Logic/workflows",
        "location": "[parameters('logicAppLocation')]",
        "tags": {
            "displayName": "LogicApp"
        },
        "apiVersion": "2016-06-01",
        "properties": {
            "definition": {
                "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                "actions": {
                    "Read_And_Use_Parameter_Value_Simple_Response": {
                        "type": "Response",
                      "inputs": {
                        "statusCode": 200,
                        "body": "The parameter value is ***@{parameters('MyFirstNewLogicAppParameter')}***"
                      },
                        "runAfter": {

                        }
                    }
                },
              "parameters": {
                "MyFirstNewLogicAppParameter": {
                  "type": "string",
                  "defaultValue": "MyFirstNewLogicAppParameterDefaultValue"
                }
              },
                "triggers": {
                    "manual": {
                        "type": "Request",
                        "kind": "Http",
                        "inputs": {
                            "schema": {

                            }
                        }
                    }
                },
                "contentVersion": "1.0.0.0",
                "outputs": {

                }
            },
            "parameters": {
              "MyFirstNewLogicAppParameter": {
                "value": "[parameters('MyFirstNewArmParameter')]"
              }
            }
        }
    }],
    "outputs": {

    }
}

クライアントは期待値を受け取ります

**パラメーター値は ***ValueIWantToSeeShowUp***** です。

こんな記事も見つけました。

http://blog.ibiz-solutions.se/integration/logic-apps-parameters-vs-arm-parameters/

URL が将来機能しなくなった場合に備えて、記事の最初の段落を以下に示します (移動された場合にインターネット検索に使用される可能性があります)。

Logic Apps パラメーターと ARM パラメーター ARM テンプレート パラメーターと Logic Apps パラメーターの違いと、これらをいつ使用する必要があるかについて質問があったので、この投稿で説明しようと思います。最初の ARM テンプレート パラメーターは ARM テンプレートと共に使用され、ARM テンプレートは ARM ベースのリソースを Azure にデプロイするときに使用され、ロジック アプリは ARM テンプレートを介してデプロイされるリソースです。ロジック アプリの背後にあるワークフロー定義言語は ARM テンプレートに非常に似ているため、最初は違いを理解するのが難しい場合があります。

著者: Mattias Lögdberg

4

1 に答える 1

17

非常に紛らわしいと思いますが、ARM テンプレート パラメーターと LogicApp パラメーターがあります。ARM パラメータを宣言しましたが、LogicApp のパラメータがありませんでした。次に、ARM パラメーターを LogicApp パラメーターに渡すことができます。

これを試して:

    {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "metadata": {
                "description": "Name of the Logic App."
            }
        },
        "logicAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "allowedValues": ["eastasia",
            "southeastasia",
            "centralus",
            "eastus",
            "eastus2",
            "westus",
            "northcentralus",
            "southcentralus",
            "northeurope",
            "westeurope",
            "japanwest",
            "japaneast",
            "brazilsouth",
            "australiaeast",
            "australiasoutheast",
            "southindia",
            "centralindia",
            "westindia",
            "canadacentral",
            "canadaeast",
            "uksouth",
            "ukwest",
            "westcentralus",
            "westus2",
            "[resourceGroup().location]"],
            "metadata": {
                "description": "Location of the Logic App."
            }
        },
        "MyFirstNewParameter": {
            "type": "string",
            "metadata": {
                "description": "Name of the MyFirstNewParameter."
            },
            "defaultValue": "My1NewParameterDefaultValue"
        }
    },
    "variables": {

    },
    "resources": [{
        "name": "[parameters('logicAppName')]",
        "type": "Microsoft.Logic/workflows",
        "location": "[parameters('logicAppLocation')]",
        "tags": {
            "displayName": "LogicApp"
        },
        "apiVersion": "2016-06-01",
        "properties": {
            "definition": {
                "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                "actions": {
                    "Read_And_Use_Parameter_Value_Simple_Response": {
                        "type": "Response",
                        "inputs": {
                            "statusCode": 200,
                            "body": "The parameter value is ***@{parameters('MyFirstNewParameter')}***"
                        },
                        "runAfter": {

                        }
                    }
                },
                "parameters": {
                    "MyFirstNewParameter": {
                        "type": "string"
                    }
                },
                "triggers": {
                    "manual": {
                        "type": "Request",
                        "kind": "Http",
                        "inputs": {
                            "schema": {

                            }
                        }
                    }
                },
                "contentVersion": "1.0.0.0",
                "outputs": {

                }
            },
            "parameters": {
                "MyFirstNewParameter": {
                    "value": "[parameters('MyFirstNewParameter')]"
                }
            }
        }
    }],
    "outputs": {

    }
}

このリンクの ARM テンプレートとパラメーターを使用して CI/CD 用にロジック アプリを準備する方法に関するいくつかのヒントとコツ: https://platform.deloitte.com.au/articles/preparing-azure-logic-apps-for-cicd

HTH

于 2017-09-06T23:48:09.607 に答える