0

我正在尝试使用二头肌在 web 应用程序上创建混合连接。

不幸的是,该文档在以下属性中没有描述RelayServiceConnectionEntityProperties

https://docs.microsoft.com/en-us/azure/templates/microsoft.web/sites/hybridconnection?tabs=bicep

这是我尝试过的:

resource webappHcm 'Microsoft.Web/sites/hybridconnection@2021-02-01' = {
  name: 'hcm'
  parent: webapp
  properties: {
    entityConnectionString: 'Endpoint=sb://xxxxxxx.servicebus.windows.net/;SharedAccessKeyName=defaultListener;SharedAccessKey=XXXXXXXXXXX;EntityPath=xxxxxxxxxxxxxxx'
    entityName: 'xxxxxxxxxxxxxxxxx'
    hostname: 'xxxxxxxxxxxxxxxxx.hostname.internal'
    port: 12345
    // resourceConnectionString: 'string'
    // resourceType: 'string'
  }
}

但是,当我尝试部署时,出现此错误:

缺少必需的参数 EntityName、EntityConnectionString、ResoureType、ResourceConnectionString、Hostname 或 BiztalkUri。

我不知道该放什么resourceConnectionStringresourceType也不知道biztalkUri
我可以在哪里找到这些想法,或者我做错了什么?

不幸的是,手动在 Azure 门户上执行,然后“导出模板”,导出没有与混合连接相关的任何内容(无论是在 Webapp 中,还是在混合连接本身中)

4

1 回答 1

1

要为网络创建混合连接,您需要具有二头肌文件,例如:

param appServiceName string

var cfg = json(loadTextContent('../../bicepConsts.json'))
var hc = cfg.HybridConnection

resource appService 'Microsoft.Web/sites@2021-02-01' existing = {
  name: appServiceName
}

var relayId = resourceId(hc.ResourceGroup, 'Microsoft.Relay/namespaces', hc.Namespace)
var connectionId = '${relayId}/hybridConnections/${hc.Name}'
var senderKeyName = 'defaultSender'

var key = listKeys('${connectionId}/authorizationRules/${senderKeyName}', '2017-04-01').primaryKey


resource hybridConnection 'Microsoft.Web/sites/hybridConnectionNamespaces/relays@2021-02-01' = {
  name: '${appService.name}/${hc.Namespace}/${hc.Name}'
  location: hc.NamespaceLocation
  dependsOn: [
    appService
  ]
  properties: {
    serviceBusNamespace: hc.Namespace
    relayName: hc.Name
    relayArmUri: connectionId
    hostname: hc.Host
    port: hc.Port
    sendKeyName: senderKeyName
    sendKeyValue: key
    serviceBusSuffix: '.servicebus.windows.net'
  }
}

此 bicepConsts 文件包含的位置如下:

{ 
    "..." : "...",
    "HybridConnection": {
        "ResourceGroup": "resource group of your HybridConnection from Azure",
        "Name": "Name of hybrid connection",
        "Namespace": "Namespace of hybrid connection",
        "NamespaceLocation": "Location (e.g. 'West US 2') of your hybrid connection namespace",
        "Host": "Host of your hybrid connection",
        "Port": "Port of your hybrid connection AS INTEGER!",
    }
}
于 2022-01-09T10:42:01.543 回答