Giter VIP home page Giter VIP logo

iac-winedge-quickstart's Introduction

Introduction

Infrastructure as Code using ARM - Windows Edge VM and Azure Container Registery.

Build Status

Create Environment File

Create an environment setting file in the root directory ie: .env.ps1 or .envrc

Default Environment Settings

Parameter Default Description
ARM_SUBSCRIPTION_ID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Azure Subscription Id
AZURE_LOCATION CentralUS Azure Region for Resources to be located

Provision Infrastructure

Note: This can be performed via Portal UI or CloudShell (Bash/Powershell)

Provision using portal

Provision using bash

Note: Requires the use of direnv

Run Install Script for ARM Process

# Initialize the Modules
initials="<your_initials>"
install.sh $initials

Provision using powershell

Note: Requires the use of powershell

Run Install Script for ARM Process

# Initialize the Modules
$initials = "<your_initials>"
install.ps1 -Initials $initials

Configure IoT Edge

  1. Connect to the Edge VM from CloudShell
$vm = "<your_vm_name>"
$group = "<your_resourceGroup>"
$cred = get-credential
Enable-AzVMPSRemoting -Name $vm -ResourceGroup $group -Protocol https -OsType Windows
Enter-AzVM -name $vm -ResourceGroup $group -Credential $cred
  1. Retrieve Connection String for Edge Device from the desired IoT Hub

  2. Configure the Edge Runtime on the Edge VM

#  Configure IOT Edge on Edge VM
$DeviceConnectionString = "<your_connection_string>"
. {Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `
Initialize-IoTEdge -Manual -DeviceConnectionString $DeviceConnectionString -ContainerOs Windows

Get-IoTEdgeLog
iotedge check

Enable Container Solution Monitoring (Optional)

Enable the Azure Container Monitoring Solution.

stop-service iotedge
stop-service iotedge-moby

# Reconfigure the iotedge-moby Service to use the following executable path
C:\Program Files\iotedge-moby\dockerd.exe -H npipe:////./pipe/docker_engine -H 0.0.0.0:2376 --exec-opt isolation=process --run-service --data-root C:\ProgramData\iotedge-moby --exec-root C:\ProgramData\iotedge-moby\\exec-root

# Start the Container Service
start-service iotedge-moby

# Test the connections
docker -H npipe:////./pipe/docker_engine images
docker -H 0.0.0.0:2376 images

# Setup Environment Variable for Docker to connect to container service.
[System.Environment]::SetEnvironmentVariable("DOCKER_HOST", "npipe:////./pipe/docker_engine", [System.EnvironmentVariableTarget]::Machine)

# --> Logoff for Environment Variable to take effect 

# Modify the config.yaml
 # uri: 'npipe://./pipe/iotedge_moby_engine'
  uri: 'npipe://./pipe/docker_engine'

# Start IoTEdge Service
start-service iotedge

# Check
iotedge check

Modify URI Schemes to HTTP for Listen and Connect (Optional)

The URI Listen and Connect URI Schemes can be modified from UNIX to HTTP in order to support .NET Framework Modules

Note: This is not recommended for a production scenario.

  1. Open the firewall rule to allow 15580 and 15581 and identify the IP Address
# Add Firewall Rule
New-NetFirewallRule -DisplayName "IoT Edge" -Direction Inbound -LocalPort 15580, 15581 -Protocol TCP -Action Allow

# Retrieve IP Address
ipconfig
  1. Edit the Configuration and modify the Connect and Listen URI's using the IP Address C:\programdata\iotedge\config.yaml

Note: Use the IP ADDRESS from the results of ipconfig

connect:
  management_uri: "http://10.0.0.4:15580"
  workload_uri: "http://10.0.0.4:15581"

listen:
  management_uri: "http://10.0.0.4:15580"
  workload_uri: "http://10.0.0.4:15581"
  1. Set the Environment Variable to access the iotedge cli tool and restart the service

Note: Use the IP ADDRESS from the results of ipconfig

# Setup the Environment variable (requires logoff to apply)
[System.Environment]::SetEnvironmentVariable("IOTEDGE_HOST", "http://10.0.0.4:15580", [System.EnvironmentVariableTarget]::Machine)

# Restart the Iot Edge Service
restart-service iotedge

iac-winedge-quickstart's People

Contributors

danielscholl avatar

Watchers

James Cloos 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.