GithubHelp home page GithubHelp logo

edgerelayservice's Introduction

DISCLAIMER: This code is provided as is without support and with minimum error checking. The code in this repo is not meant for use in production.

This code uses the libraries from https://github.com/AndreasM009/azure-relay-portbridge/tree/master/AzureRelayPortBridge

Build the docker container in project PortBridgeServiceEdge and push it to your container registry.
Create an IoT Edge device and add the module PortBridgeServiceEdge to the device.

Create a relay namespace and a hybrid connection. https://docs.microsoft.com/en-us/azure/azure-relay/relay-create-namespace-portal
You can use the key for the RootManageSharedAccessKey policy. Or you can generate policies for send, receive or send/receive. 
Typically the device side needs Listen privileges while the client side needs send privileges. A policy with send and receive should work for both.

Use the TokenGenerator project to get a token for the relay service. 
You will need to enter the relevant values in the program to generate the token.
Run the TokenGenerator and copy the resulting Token which looks like : SharedAccessSignature sr=**************************************************

The module has two direct methods StartRelay and StopRelay

To start the relay service invoke StartRelay method with the following method body:

{
  "HybridConnectionServerHost": {
    "ServiceBusNamespace": "{service bus namespace}",
    "ServiceBusSasToken": "{token generated as above}",
    "ForwardingRules": [
      {
        "ServiceBusConnectionName": "{name of Hybrid Connection}",
        "TargetHostname": "{IP or hostname of target}",
        "TargetPorts": "{target port e.g. 22}",
        "InstanceCount": 1 (or more if needed)
      }
    ]
  }
}

if the method invocation is successful you should get a listener connection on the Hybridconnection portal 

Now start the PortBridgeClient application (after entering the correct values in the appsettings.json), remember that the client needs "send" rights.

If all is ok then you can now start the connection to the device for example using ssh to localhost on port 2222 (based on the port used in the client's appsetting.json)

When finished make sure to stop the relay service by invoking a direct method on the module with method name StopRelay with empty method payload

The module should work even if the device is behind an http proxy. There is no need to have open ports on the device.

Currenlty there is not much error checking so the payload for the method StartRelay needs to be correct otherwise it will crash.

edgerelayservice's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.