Список программ, которые нужно установить для разработки модулей IoT Edge под Visual Studio: https://docs.microsoft.com/ru-ru/azure/iot-edge/how-to-visual-studio-develop-csharp-module.
- Запустить инсталлятор Visual Studio 2017 и добавляем пункт «Разработка для Azure».
- Установить Azure IoT Edge extension из Visual Studio marketplace для создания новых проектов IoT Edge в Visual Studio 2017.
- Установить Docker Community Edition на ПК, где будет происходить разработка для сборки и запуска образов модулей.
- Для отладки, запуска и тестирования IoT Edge модулей нужно установить Azure IoT EdgeHub Dev Tool. Для этого нужно:
- Установить Python (2.7/3.6) and Pip. С дтистрибутивом в комплекте идет pip.
- Перейти в папку C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python37-32. Название последней папки может изменится.
- pip может быть старой версии, поэтому имеет смысл выполнить команду: python.exe -m pip install —upgrade pip.
- Для установки iotedgehubdev нужно выполнить следующую команду в командной строке (cmd):
pip install --upgrade iotedgehubdev.pip находится в папке C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python37-32\Scripts\
- Создаем реестр контейнеров Azure Container Registry or Docker Hub:
- В Azure запускаем консоль Azure CLI.
- Выполняем скрипт Azure CLI: CreateContainerRegistry
#Azure CLI version 2.0.27 or later #https://docs.microsoft.com/ru-ru/azure/container-registry/container-registry-get-started-azure-cli #$resource_group_name = "IoTEdgeResources" $resource_group_name = "RemoteMonitoringTest1018" $ContainerRegistryName = "RemoteMonitoringContainterRegistry1018" $ContainerName = "acr-quickstart" $dns_name_label = "shneider" #Create a resource group named myResourceGroup in the eastus location. az group create --name $resource_group_name --location westeurope #create a Basic registry. Azure Container Registry is available in several different SKUs: Basic, Standard, Premium. #The registry name must be unique within Azure, and contain 5-50 alphanumeric characters. #After finishing the command - new resource will be available in Azure "All resources". az acr create --resource-group $resource_group_name --name $ContainerRegistryName --sku Basic #Before pushing and pulling container images, you must log in to the ACR instance. To do so, use the az acr login command. #The result can be "This command requires running the docker daemon, which is not supported in Azure Cloud Shell." #Just ignore and go the next steps az acr login --name $ContainerRegistryName #To push an image to an Azure Container registry, you must first have an image. If you don't yet have any local container images, #run the following command to pull test image "aci-helloworld" from Docker Hub. #Run the command on the developer PC where Docker was installed. #docker pull microsoft/aci-helloworld #Before you can push an image to your registry, you must tag it with the fully qualified name of your ACR login server. #Run the following command to obtain the full login server name <acrLoginServer> of the ACR instance. az acr list --resource-group $resource_group_name --query "[].{acrLoginServer:loginServer}" --output table #Tag the image using the docker tag command. Replace <acrLoginServer> with the login server name of your ACR instance. #Run the command on the developer PC where Docker was installed. #docker tag microsoft/aci-helloworld <acrLoginServer>/aci-helloworld:v1 #Login to your container registry #In Azure go to: "All resources" -> <Your container registry> -> "Access keys" #Switch "Admin user" to "Enable" to get the username and password. #You can do this operations by commands: az acr update --name <acrName> --admin-enabled true az acr credential show --name $ContainerRegistryName --query "passwords[0].value" #Run the command on the developer PC where Docker was installed. #docker login <acrLoginServer> --username $ContainerRegistryName --password <password from Access Keys> #Use docker push to push the image to the ACR instance. Replace <acrLoginServer> with the login server name of your ACR instance. #Run the command on the developer PC where Docker was installed. #docker push <acrLoginServer>/aci-helloworld:v1 #The following command lists the repositories in a registry. az acr repository list --name $ContainerRegistryName --output table #The following example lists the tags on the aci-helloworld repository. #aci-helloworld should be replaced for the result of the previous command az acr repository show-tags --name $ContainerRegistryName --repository aci-helloworld --output table #To deploy your container image with 1 CPU core and 1 GB of memory, run the following command. #Replace <acrName>, <acrLoginServer>, and <acrPassword> with the values you obtained from previous commands. #https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az-container-create #Example: #az container create --resource-group $resource_group_name --name $ContainerName --image remotemonitoringcontainterregistry1018.azurecr.io/aci-helloworld:v1 --cpu 1 --memory 1 --registry-username $ContainerRegistryName --registry-password wQQogP5DLV7q8=5r60YQx8lnKrSDo54D --dns-name-label $dns_name_label --ports 80 az container create --resource-group $resource_group_name --name $ContainerName --image <acrLoginServer>/aci-helloworld:v1 --cpu 1 --memory 1 --registry-username $ContainerRegistryName --registry-password <acrPassword> --dns-name-label $dns_name_label --ports 80 #Once the deployment to ACI is successful, retrieve the container's FQDN with the az container show command: az container show --resource-group $resource_group_name --name $ContainerName --query ipAddress.fqdn #Clean up resources #When no longer needed, you can use the az group delete command to remove the resource group, ACR instance, and all container images. #!!!!! WARNING !!!!! #az group delete --name $resource_group_name - Можно использовать локальный Docker для прототипирования и тестирования вместо использования облачного реестра.
- Для тестирования разработанного модуля необходтимо активировать IoT hub хотя-бы с одним созданным IoT Edge ID устройством.
- Если IoT Edge security daemon запускается на ПК разработчика, возможно, потребуется отстановить EdgeHub и EdgeAgent перед запуском разработчик в Visual Studio.