if [[ $# != 7 ]] ; then printf "YOU NEED TO INCLUDE THE FOLLOWING 7 PARAMETERS SEPARATED BY A SPACE IN ORDER \n CONTAINER REGISTRY NAME \n CONTAINER REGISTRY USER NAME \n CONTAINER REGISTRY PASSWORD \n IMAGE LOCATION URL \n DESIRED IOT DEPLOYMENT NAME \n IOT HUB NAME \n IOT DEVICE NAME TO TARGET \n" exit 0 fi regname=$1 user=$2 password=$3 imagelocation=$4 iot_deployment_id=$5 iot_hub_name=$6 iot_device_id=$7 echo WRITING YOUR CONFIGURATION FILE echo " { \"modulesContent\": { \"$edgeAgent\": { \"properties.desired\": { \"schemaVersion\": \"1.0\", \"runtime\": { \"type\": \"docker\", \"settings\": { \"minDockerVersion\": \"v1.25\", \"loggingOptions\": \"\", \"registryCredentials\": { \"$regname\":{ \"username\": \"$username\", \"password\": \"$password\", \"address\": \"$regname.azurecr.io\", } } } }, \"systemModules\": { \"edgeAgent\": { \"type\": \"docker\", \"settings\": { \"image\": \"mcr.microsoft.com/azureiotedge-agent:1.0\", \"createOptions\": \"{}\", \"env\": { \"UpstreamProtocol\": { \"value\": \"MQTT\" } } } }, \"edgeHub\": { \"type\": \"docker\", \"status\": \"running\", \"restartPolicy\": \"always\", \"settings\": { \"image\": \"mcr.microsoft.com/azureiotedge-hub:1.0\", \"createOptions\": \"{\"User\":\"root\",\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}], \"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}\", \"env\": { \"UpstreamProtocol\": { \"value\": \"MQTT \" } } } } }, \"modules\": { \"VisionSampleModule\": { \"version\": \"1.0\", \"type\": \"docker\", \"status\": \"running\", \"restartPolicy\": \"always\", \"settings\": { \"image\": \"$imagelocation\", \"createOptions\": \"{\"HostConfig\":{\"Binds\":[\"/data/misc/camera:/app/vam_model_folder\"],\"NetworkMode\":\"host\"},\"NetworkingConfig\":{\"EndpointsConfig\":{\"host\":{}}}}\" } } } } }, \"$edgeHub\": { \"properties.desired\": { \"schemaVersion\": \"1.0\", \"routes\": { \"route\": \"FROM /messages/* INTO $upstream\" }, \"storeAndForwardConfiguration\": { \"timeToLiveSecs\": 7200 } } } } } " > deploy.json echo DEPLOYING $iot_deployment_id ... az iot edge deployment create --deployment-id $iot_deployment_id --content \"deployment.json\" --hub-name $iot_hub_name --target-condition "deviceId='$iot_device_id'" --priority 1 echo DONE