Azure 从ARM模板部署Logic App自定义连接器时设置身份验证

Azure 从ARM模板部署Logic App自定义连接器时设置身份验证,azure,arm-template,Azure,Arm Template,我正在通过arm模板部署Logic应用程序自定义连接器。在ARM模板中,类型为Microsoft.Web/customApi 我们还正在部署连接器(Microsoft.Web/connections) 项目部署正常,但基本身份验证参数未在customApi和连接之间正确链接 尽管参数的显示名称反映在连接中,但这似乎一切正常(注意,密码应该是空的,我们使用的testrestapi只需要用户名): 如果我们将显示名称添加到自定义连接器中,并更新该连接,它就会工作。这是自定义连接器更新后的外观:

我正在通过arm模板部署Logic应用程序自定义连接器。在ARM模板中,类型为Microsoft.Web/customApi

我们还正在部署连接器(Microsoft.Web/connections)

项目部署正常,但基本身份验证参数未在customApi和连接之间正确链接

尽管参数的显示名称反映在连接中,但这似乎一切正常(注意,密码应该是空的,我们使用的testrestapi只需要用户名):

如果我们将显示名称添加到自定义连接器中,并更新该连接,它就会工作。这是自定义连接器更新后的外观:

因此,我们希望在不需要手动步骤的情况下,完全从ARM部署中实现这一点。可能吗?Microsoft.Web/customApi的文档没有提供有关您可以提供的connectionParameters的任何详细信息

customApi的ARM代码段:

 "type": "Microsoft.Web/customApis",
  "name": "[variables('CustomConnectorName')]",
  "apiVersion": "2016-06-01",
  "location": "[variables('resourceGroupLocation')]",
  "tags": {
    "Environment": "[variables('environment')]"
  },
  "scale": null,
  "properties": {
    "capabilities": [
      "gateway"
    ],
    "connectionParameters": {
      "username": {
        "type": "string",
        "uiDefinition": {
          "displayName": "ConnectionUsername",              
          "description": "The UserName for this api",
          "tooltip": "Provide the UserName",
          "constraints": {
            "tabIndex": 2,
            "clearText": true,
            "required": "true"
          }
        }
      },
      "password": {
        "type": "string",
        "uiDefinition": {
          "displayName": "ConnectionPassword",              
          "description": "The Password for this api",
          "tooltip": "Provide the Password",
          "constraints": {
            "tabIndex": 3,
            "clearText": false,
            "required": "false"
          }
        }
      },
      "authType": {
        "type": "string",
        "allowedValues": [
          {
            "value": "basic"
          }
        ],
        "uiDefinition": {
          "displayName": "Authentication Type",
          "description": "Authentication type to connect to your API",
          "tooltip": "Authentication type to connect to your API",
          "constraints": {
            "tabIndex": 1,
            "required": "true",
            "allowedValues": [
              {
                "text": "basic",
                "value": "basic"
              }
            ]
          }
        }
      },
      "gateway": {
        "type": "gatewaySetting",
        "gatewaySettings": {
          "dataSourceType": "CustomConnector",
          "connectionDetails": []
        },
        "uiDefinition": {
          "constraints": {
            "tabIndex": 4,
            "required": "true",
            "capability": [
              "gateway"
            ]
          }
        }
      }
    },
连接的ARM代码段:

 "type": "Microsoft.Web/connections",
  "apiVersion": "2016-06-01",
  "location": "[resourceGroup().location]",
  "name": "MyCustomConnector",
  "properties": {
    "api": {
      "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',resourceGroup().name,'/providers/Microsoft.Web/customApis/MyCustomConnector')]"
    },
    "displayName": "MyCustomConnector",
    "parameterValues": {
      "username": "[variables('UserName')]",
      "password": "[variables('Password')]",
      "authType": "basic",
      "gateway": {
        "id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',variables('coreResourceGroupName'),'/providers/Microsoft.Web/connectionGateways/',variables('onPremiseGatewayName'))]"
      }
    }
  }
}
如果您能就如何使用保存的正确参数名部署customApi,从而消除手动步骤的需要提出建议,我将不胜感激


谢谢

在部署自定义连接器时,用户应使用各自的
apikey
或连接器使用的任何身份验证来创建连接

所以我修改了你的模板一点,它似乎工作的预期

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "resources": [
        {
            "type": "Microsoft.Web/customApis",
            "apiVersion": "2016-06-01",
            "name": "Test",
            "location": "[resourceGroup().location]",
            "properties": {
                "capabilities": [
                    "gateway"
                ],
                "connectionParameters": {
                    "username": {
                        "type": "string",
                        "uiDefinition": {
                            "displayName": "ConnectionUsername",
                            "description": "The UserName for this api",
                            "tooltip": "Provide the UserName",
                            "constraints": {
                                "tabIndex": 2,
                                "clearText": true,
                                "required": "true"
                            }
                        }
                    },
                    "password": {
                        "type": "string",
                        "uiDefinition": {
                            "displayName": "ConnectionPassword",
                            "description": "The Password for this api",
                            "tooltip": "Provide the Password",
                            "constraints": {
                                "tabIndex": 3,
                                "clearText": false,
                                "required": "false"
                            }
                        }
                    },
                    "authType": {
                        "type": "string",
                        "allowedValues": [
                            {
                                "value": "basic"
                            }
                        ],
                        "uiDefinition": {
                            "displayName": "Authentication Type",
                            "description": "Authentication type to connect to your API",
                            "tooltip": "Authentication type to connect to your API",
                            "constraints": {
                                "tabIndex": 1,
                                "required": "true",
                                "allowedValues": [
                                    {
                                        "text": "basic",
                                        "value": "basic"
                                    }
                                ]
                            }
                        }
                    },
                    "gateway": {
                        "type": "gatewaySetting",
                        "gatewaySettings": {
                            "dataSourceType": "CustomConnector",
                            "connectionDetails": []
                        },
                        "uiDefinition": {
                            "constraints": {
                                "tabIndex": 4,
                                "required": "true",
                                "capability": [
                                    "gateway"
                                ]
                            }
                        }
                    }
                },
                "backendService": {
                    "serviceUrl": "[concat('https://helloWorld.azurewebsites.net/')]"
                }
            }
        }
    ]
}
下面是您尝试从
LogicApp

注意从
[变量('resourceGroupLocation')]
[资源组().location]
的更改,它实际上是arm模板中内置的东西,您可以访问模板指向的当前资源组的位置

我还添加了一个
backendService
,它将指向您的API URL


希望这有帮助。

在部署自定义连接器时,用户应使用各自的
apikey
或连接器使用的任何身份验证来创建连接

所以我修改了你的模板一点,它似乎工作的预期

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "resources": [
        {
            "type": "Microsoft.Web/customApis",
            "apiVersion": "2016-06-01",
            "name": "Test",
            "location": "[resourceGroup().location]",
            "properties": {
                "capabilities": [
                    "gateway"
                ],
                "connectionParameters": {
                    "username": {
                        "type": "string",
                        "uiDefinition": {
                            "displayName": "ConnectionUsername",
                            "description": "The UserName for this api",
                            "tooltip": "Provide the UserName",
                            "constraints": {
                                "tabIndex": 2,
                                "clearText": true,
                                "required": "true"
                            }
                        }
                    },
                    "password": {
                        "type": "string",
                        "uiDefinition": {
                            "displayName": "ConnectionPassword",
                            "description": "The Password for this api",
                            "tooltip": "Provide the Password",
                            "constraints": {
                                "tabIndex": 3,
                                "clearText": false,
                                "required": "false"
                            }
                        }
                    },
                    "authType": {
                        "type": "string",
                        "allowedValues": [
                            {
                                "value": "basic"
                            }
                        ],
                        "uiDefinition": {
                            "displayName": "Authentication Type",
                            "description": "Authentication type to connect to your API",
                            "tooltip": "Authentication type to connect to your API",
                            "constraints": {
                                "tabIndex": 1,
                                "required": "true",
                                "allowedValues": [
                                    {
                                        "text": "basic",
                                        "value": "basic"
                                    }
                                ]
                            }
                        }
                    },
                    "gateway": {
                        "type": "gatewaySetting",
                        "gatewaySettings": {
                            "dataSourceType": "CustomConnector",
                            "connectionDetails": []
                        },
                        "uiDefinition": {
                            "constraints": {
                                "tabIndex": 4,
                                "required": "true",
                                "capability": [
                                    "gateway"
                                ]
                            }
                        }
                    }
                },
                "backendService": {
                    "serviceUrl": "[concat('https://helloWorld.azurewebsites.net/')]"
                }
            }
        }
    ]
}
下面是您尝试从
LogicApp

注意从
[变量('resourceGroupLocation')]
[资源组().location]
的更改,它实际上是arm模板中内置的东西,您可以访问模板指向的当前资源组的位置

我还添加了一个
backendService
,它将指向您的API URL


希望这能有所帮助。

如果您使用swagger对API建模,您可以将安全需求定义为swagger的一部分。我使用了用于基本身份验证的API密钥方法,虽然我认为您可能可以按照要求使用基本方法,但我只是没有尝试。

下面是我在ARM模板中使用的Microsoft.Web/customAPI JSON类型上的swagger属性的一个示例(为简洁起见,请删节)


部署时,可使用自定义连接器的安全部分以及定义良好的端点。

如果使用swagger对API建模,则可以将安全要求定义为swagger的一部分。我使用了用于基本身份验证的API密钥方法,虽然我认为您可能可以按照要求使用基本方法,但我只是没有尝试。

下面是我在ARM模板中使用的Microsoft.Web/customAPI JSON类型上的swagger属性的一个示例(为简洁起见,请删节)


部署后,可以使用自定义连接器的安全部分以及定义良好的端点。

您好,HariHaran,谢谢您的输入。我们指定了backendService URL,但我没有包含全部代码,因为这一点似乎可以正常工作。我们试图实现的是没有手动步骤——我们还通过ARM部署了Logic应用程序,希望它能够使用我们正在创建的customApi和连接,而无需任何人进入门户并在门户中手动执行任何操作。我们将其归结为一个手动步骤,即在customApi的安全屏幕中确认参数标签,但这不可能自动化,这似乎很奇怪。谢谢,Matt。@matthew-7.7如果您在部署过程中创建连接,最好不要使用身份验证机制。我们有一些接口,其中没有身份验证可以与其他系统通信,而且一切正常。但是我们需要接口的一些系统需要基本的身份验证。嗨,HariHaran,谢谢你的输入。我们指定了backendService URL,但我没有包含全部代码,因为这一点似乎可以正常工作。我们试图实现的是没有手动步骤——我们还通过ARM部署了Logic应用程序,希望它能够使用我们正在创建的customApi和连接,而无需任何人进入门户并在门户中手动执行任何操作。我们将其归结为一个手动步骤,即在customApi的安全屏幕中确认参数标签,但这不可能自动化,这似乎很奇怪。谢谢,Matt。@matthew-7.7如果您在部署过程中创建连接,最好不要使用身份验证机制。我们有一些接口,其中没有身份验证可以与其他系统通信,而且一切正常。但是我们需要接口的一些系统需要基本的身份验证。我知道这是一篇老文章,但我遇到了一个类似的问题,并让它正常工作。在上面的示例ARM模板JSON中,我注意到用户名和密码“type”被设置为“string”。尝试将其设置为“securestring”。我还注意到,在连接的ARM代码段中,用户名和密码值是使用[variables]设置的。。。是这样吗?我的手臂模板