Get started with Azure Relay Hybrid Connections – Using Apache Thrift Listener

The Azure Relay Hybrid Connections service enables you to securely expose services that reside on-prem to the public cloud, without having to open a firewall connection or require intrusive changes to a corporate network infrastructure.

You can follow the steps outlined in the document Get started with Relay Hybrid Connections.

You can find another example at Github, Azure Relay Hybrid Connections - Apache Thrift Listener. When you update or add the reference to “Microsoft.Azure.Relay”, make sure that you use the dll in the net45 folder, not the dll in the netstandard1.3 folder. You can download the branch version at Github.

image

If you download the Azure Relay .NET project from Github, without using the Microsoft.Azure.Relay package from NuGet Package Manager, make sure that you have the same or newer .Net sdk version in the global.json file. For example, change it from "version": "1.0.0-preview2-003121" to "version": "1.0.0-preview2-003131" if you have version “1.0.0-preview2-003131” installed, which you can find from the control panel, “Programs and Features.”

image

Also, if you create the namespace using the deployment template at the Github, you get two hybrid connections, “Authenticated” which requires authentication on Azure and “Unauthenticated”, which doesn’t require authentication. You will get the default policy, RootManageSharedAccessKey for both connections. But you can create one shared access policy for “Authenticated” connection from the portal and choose the right permissions, “Manage”, “Listen” and “Send”.

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namespaceName": {
"type": "string",
"metadata": {
"description": "Name of the Azure Relay namespace"
}
}
},
"variables": {
"location": "[resourceGroup().location]",
"apiVersion": "2016-07-01",
"defaultSASKeyName": "RootManageSharedAccessKey",
"defaultAuthRuleResourceId": "[resourceId('Microsoft.Relay/namespaces/authorizationRules', parameters('namespaceName'), variables('defaultSASKeyName'))]"
},
"resources": [
{
"apiVersion": "[variables('apiVersion')]",
"name": "[parameters('namespaceName')]",
"type": "Microsoft.Relay/Namespaces",
"location": "[variables('location')]",
"kind": "Relay",
"resources": [
{
"apiVersion": "[variables('apiVersion')]",
"name": "authenticated",
"type": "HybridConnections",
"dependsOn": [
"[concat('Microsoft.Relay/namespaces/', parameters('namespaceName'))]"
],
"properties": {
"path": "authenticated"
}
},
{
"apiVersion": "[variables('apiVersion')]",
"name": "unauthenticated",
"type": "HybridConnections",
"dependsOn": [
"[concat('Microsoft.Relay/namespaces/', parameters('namespaceName'))]"
],
"properties": {
"path": "unauthenticated",
"RequiresClientAuthorization": false
}
}
],
"properties": {}
}
],
"outputs": {
"NamespaceConnectionString": {
"type": "string",
"value": "[listkeys(variables('defaultAuthRuleResourceId'), variables('apiVersion')).primaryConnectionString]"
}
}
}

 

image

Once that’s all done, you can build the client app (console app) and the server app (console app). Navigate to the folders where the apps, server.exe and client.exe, are located, and run the command lines below, each in its own console environment. The client app uses the calculator service to add, subtract, and divide two numbers, and the server app echo the results.

server zxuerelay1.servicebus.windows.net authenticated policy1 8nawZQXyR3Fx82r+k5iV0wjrdgW2iPVs8/4bTu3Jqbo=

client zxuerelay1.servicebus.windows.net authenticated policy1 8nawZQXyR3Fx82r+k5iV0wjrdgW2iPVs8/4bTu3Jqbo=

 

image

image