0

I'm trying to create an Hybrid Connection on a webapp using Bicep.

The documentation, unfortunately, has no descriptions in the properties of RelayServiceConnectionEntityProperties:

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

This is what I tried:

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'
  }
}

However, when I try to deploy, I get this error:

Required parameter EntityName, EntityConnectionString, ResoureType, ResourceConnectionString, Hostname, or BiztalkUri is missing.

I have no idea what to put in resourceConnectionString, resourceType nor biztalkUri.
Any ideas where I can find those, or what am I doing wrong?

Unfortunately, doing it on the Azure Portal manually, and then "Export template", the export doesn't have anything related to the hybrid connection (whether it is in the Webapp, or in the Hybrid Connection itself)

Nuno
  • 3,082
  • 5
  • 38
  • 58
  • have you tried using `az rest` https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az_rest? it gives most of the time more information – Thomas Oct 29 '21 at 01:04
  • it should be something like that `az rest --method get --uri {resourceid}?api-version=yyyy-mm-dd` – Thomas Oct 29 '21 at 01:05
  • `resourceConnectionString` is the gateway connection string in the Hybrid Connection properties in the [Azure portal](https://portal.azure.com/). `resourceType`is type of resources like `"Microsoft.Web/sites"` –  Oct 29 '21 at 14:23
  • Any update to the issue? –  Oct 30 '21 at 05:21

1 Answers1

2

for creating Hybrid-Connection for webs you need to have bicep file like:

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'
  }
}

Where this bicepConsts file contains think like:

{ 
    "..." : "...",
    "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!",
    }
}
KondzioSSJ4
  • 220
  • 4
  • 12