在 ARM 模板中创建 Azure AD 集成 SQL Server 连接

Red*_*ard 5 azure-logic-apps azure-rm-template

看起来我们现在可以使用逻辑应用程序中的 SQL Server 连接器对 Azure AD 进行身份验证,这太棒了!

这是新连接器下拉菜单的屏幕截图

我的问题是当我通过 ARM 模板更改此连接器的名称时,当我在 Azure Api 连接刀片中为该连接选择“编辑 Api 连接”时,我不再有 Azure AD 集成选项,它看起来像 SQL Server身份验证连接。

从逻辑应用创建连接时与 Azure AD 集成的 Api 连接

从 ARM 模板创建时的 Api 连接

从我所看到和尝试的情况来看,当我从 Azure 导出模板时,它们看起来完全相同。以下是示例。

从 Azure AD 集成连接导出模板:

"resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('azure_ad_authenticated_connection')]",
            "location": "<valid_location>",
            "properties": {
                "displayName": "{<db_name>} {<db_server_name>}",
                "customParameterValues": {},
                "api": {
                    "id": "[concat('/subscriptions/<subscription_id>/providers/Microsoft.Web/locations/<location>/managedApis/', parameters('connections_sql_name'))]"
                }
            }
        }
    ]
Run Code Online (Sandbox Code Playgroud)

从 SQL Server 身份验证连接导出的模板:

"resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('sql_server_auth_connection')]",
            "location": "<valid_location>",
            "properties": {
                "displayName": "<display_name>",
                "customParameterValues": {},
                "api": {
                    "id": "[concat('/subscriptions/<subscription_id>/providers/Microsoft.Web/locations/<valid_location>/managedApis/sql')]"
                }
            }
        }
    ]
Run Code Online (Sandbox Code Playgroud)

有没有人能够从 ARM 模板成功创建 Azure AD 集成连接?

小智 1

确实,是要变得疯狂!

当 Azure 导出 ARM 模板时,它永远不会包含必须保持安全的参数。因此,您最终会得到一个不完整的 ARM 模板。在你的情况下你必须添加

"parameterValueSet": {
  "name": "oauth",
  "values": {}
}
Run Code Online (Sandbox Code Playgroud)

完整的模板是:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "sql_Connection_Name": {
      "defaultValue": "sqlConnectionWithOAuth",
      "type": "String"
    },
    "sql_Connection_DisplayName": {
      "defaultValue": "sql Connection with OAuth",
      "type": "String"
    },
    "logicAppLocation": {
      "defaultValue": "westeurope",
      "type": "String"
    }
  },
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.Web/connections",
      "apiVersion": "2016-06-01",
      "name": "[parameters('sql_Connection_Name')]",
      "location": "[parameters('logicAppLocation')]",
      "properties": {
        "displayName": "[parameters('sql_Connection_DisplayName')]",
        "customParameterValues": {},
        "api": {
          "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sql')]",
          "type": "Microsoft.Web/locations/managedApis"
        },
        "parameterValueSet": {
          "name": "oauth",
          "values": {}
        }
      }
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

如果有进一步的需求,您可以使用ARMclient来找出丢失的参数。对于sql api连接:

armclient.exe get https://management.azure.com/subscriptions/{SubscriptionId}/Microsoft.Web/locations/{LogicAppLocation}/managedApis/sql?api-version=2016-06-01
Run Code Online (Sandbox Code Playgroud)

你会得到一个很长的 json 描述,其中包含“ oauth ”参数:

"name": "oauth",
"uiDefinition": {
  "displayName": "Azure AD Integrated",
  "description": "Use Azure Active Directory to access your SQL database."
},
Run Code Online (Sandbox Code Playgroud)