You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过ARM模板将现有Hybrid Connection添加至Azure应用服务计划

配置Azure App Service Plan关联现有Hybrid Connection的ARM模板修改方案

Hybrid Connection的关联配置不能直接在App Service Plan(Microsoft.Web/serverfarms)资源中设置,需要在对应的Standard Logic App(本质属于Microsoft.Web/sites类型资源)下添加hybridConnections子资源,以此关联现有Hybrid Connection。以下是具体修改步骤:

1. 确认App Service Plan的SKU要求

你的现有模板中,App Service Plan的SKU Tier为Standard,这满足Hybrid Connections的使用要求(仅Standard及以上层支持),无需修改这部分内容。

2. 添加Hybrid Connection关联资源

在ARM模板中新增Microsoft.Web/sites/hybridConnections类型的资源,关联到目标Logic App和现有Hybrid Connection。

完整模板示例(包含原有App Service Plan资源)

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string",
            "metadata": {
                "description": "资源部署位置"
            }
        },
        "hostingPlanName": {
            "type": "string",
            "metadata": {
                "description": "App Service Plan名称"
            }
        },
        "numberOfWorkers": {
            "type": "int",
            "defaultValue": 1,
            "metadata": {
                "description": "工作者实例数量"
            }
        },
        "workerSize": {
            "type": "string",
            "defaultValue": "Small",
            "metadata": {
                "description": "工作者实例大小"
            }
        },
        "workerSizeId": {
            "type": "int",
            "defaultValue": 0,
            "metadata": {
                "description": "工作者实例大小ID"
            }
        },
        "skuCode": {
            "type": "string",
            "defaultValue": "S1",
            "metadata": {
                "description": "SKU代码"
            }
        },
        "sku": {
            "type": "string",
            "defaultValue": "Standard",
            "metadata": {
                "description": "SKU层级"
            }
        },
        // 新增Hybrid Connection相关参数
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Logic App名称"
            }
        },
        "hybridConnectionName": {
            "type": "string",
            "metadata": {
                "description": "现有Hybrid Connection的名称"
            }
        },
        "hybridConnectionNamespace": {
            "type": "string",
            "metadata": {
                "description": "Hybrid Connection所在的Relay命名空间名称"
            }
        },
        "hybridConnectionResourceGroupName": {
            "type": "string",
            "defaultValue": "[resourceGroup().name]",
            "metadata": {
                "description": "Hybrid Connection所在的资源组名称,默认同当前模板资源组"
            }
        },
        "hybridConnectionHostname": {
            "type": "string",
            "metadata": {
                "description": "Hybrid Connection连接的本地主机名"
            }
        },
        "hybridConnectionPort": {
            "type": "int",
            "metadata": {
                "description": "Hybrid Connection连接的本地端口"
            }
        }
    },
    "resources": [
        // 原有App Service Plan资源
        {
            "apiVersion": "2022-09-01",
            "dependsOn": [],
            "location": "[parameters('location')]",
            "name": "[parameters('hostingPlanName')]",
            "properties": {
                "maximumElasticWorkerCount": 20,
                "name": "[parameters('hostingPlanName')]",
                "numberOfWorkers": "[parameters('numberOfWorkers')]",
                "workerSize": "[parameters('workerSize')]",
                "workerSizeId": "[parameters('workerSizeId')]",
                "zoneRedundant": false
            },
            "sku": {
                "name": "[parameters('skuCode')]",
                "tier": "[parameters('sku')]"
            },
            "type": "Microsoft.Web/serverfarms"
        },
        // 新增Hybrid Connection关联资源
        {
            "apiVersion": "2022-09-01",
            "type": "Microsoft.Web/sites/hybridConnections",
            "name": "[concat(parameters('logicAppName'), '/', parameters('hybridConnectionName'))]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
                "[resourceId('Microsoft.Logic/workflows', parameters('logicAppName'))]"
            ],
            "properties": {
                "serviceBusNamespace": "[parameters('hybridConnectionNamespace')]",
                "relayName": "[parameters('hybridConnectionName')]",
                "relayArmUri": "[resourceId(parameters('hybridConnectionResourceGroupName'), 'Microsoft.Relay/namespaces/hybridConnections', parameters('hybridConnectionNamespace'), parameters('hybridConnectionName'))]",
                "hostname": "[parameters('hybridConnectionHostname')]",
                "port": "[parameters('hybridConnectionPort')]",
                "sendKeyName": "RootManageSharedAccessKey"
            }
        }
    ]
}

关键配置说明

  • relayArmUri:通过resourceId函数引用现有Hybrid Connection的资源ID,若Hybrid Connection与当前模板在同一资源组,可直接使用默认参数值;若不在,需指定对应的资源组名称。
  • sendKeyName:默认使用Relay命名空间的RootManageSharedAccessKey,若配置了自定义访问密钥,可替换为对应的密钥名称。
  • dependsOn:确保Hybrid Connection资源在App Service Plan和Logic App部署完成后再创建,避免依赖问题。

内容的提问来源于stack exchange,提问作者serkanz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 04:57:09