AzureIoTEdge@2 - Azure IoT Edge v2 任务
语法
# Azure IoT Edge v2
# Build and deploy an Azure IoT Edge image.
- task: AzureIoTEdge@2
inputs:
action: 'Build module images' # 'Build module images' | 'Push module images' | 'Generate deployment manifest' | 'Deploy to IoT Edge devices'. Required. Action. Default: Build module images.
#deploymentFilePath: '$(System.DefaultWorkingDirectory)/config/deployment.json' # string. Required when action == Deploy to IoT Edge devices. Deployment file. Default: $(System.DefaultWorkingDirectory)/config/deployment.json.
#azureSubscription: # string. Alias: connectedServiceNameARM. Required when action == Deploy to IoT Edge devices. Azure subscription contains IoT Hub.
#iothubname: # string. Required when action == Deploy to IoT Edge devices. IoT Hub name.
#deviceOption: # 'Single Device' | 'Multiple Devices'. Required when action == Deploy to IoT Edge devices. Choose single/multiple device.
#deviceId: # string. Required when deviceOption == Single Device. IoT Edge device ID.
#targetcondition: # string. Required when deviceOption == Multiple Devices. IoT Edge device target condition.
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Generic Container Registry'. Required when action = Push module images. Container registry type. Default: Azure Container Registry.
#dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Required when containerregistrytype = Generic Container Registry. Docker Registry Connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription.
#azureContainerRegistry: # string. Required when containerregistrytype = Azure Container Registry. Azure Container Registry.
#templateFilePath: 'deployment.template.json' # string. Required when action = Build module images || action = Push module images || action = Generate deployment manifest. .template.json file. Default: deployment.template.json.
#defaultPlatform: 'amd64' # 'amd64' | 'windows-amd64' | 'arm32v7' | 'arm64v8'. Required when action = Build module images || action = Push module images || action = Generate deployment manifest. Default platform. Default: amd64.
#fillRegistryCredential: 'true' # 'true' | 'false'. Required when action = Push module images. Add registry credential to deployment manifest. Default: true.
#deploymentManifestOutputPath: '$(System.DefaultWorkingDirectory)/config/deployment.json' # string. Required when action == Generate deployment manifest. Output path. Default: $(System.DefaultWorkingDirectory)/config/deployment.json.
#validateGeneratedDeploymentManifest: 'false' # 'true' | 'false'. Required when action = Generate deployment manifest. Validate the schema of generated deployment manifest. Default: false.
# Advanced
#deploymentid: '$(System.TeamProject)-devops-deployment' # string. Required when action = Deploy to IoT Edge devices. IoT Edge deployment ID. Default: $(System.TeamProject)-devops-deployment.
#priority: '0' # string. Required when action = Deploy to IoT Edge devices. IoT Edge deployment priority. Default: 0.
# Advanced
#bypassModules: # string. Optional. Use when action = Push module images. Bypass module(s).
# Azure IoT Edge v2
# Build and deploy an Azure IoT Edge image.
- task: AzureIoTEdge@2
inputs:
action: 'Build module images' # 'Build module images' | 'Push module images' | 'Generate deployment manifest' | 'Deploy to IoT Edge devices'. Required. Action. Default: Build module images.
#deploymentFilePath: '$(System.DefaultWorkingDirectory)/config/deployment.json' # string. Required when action == Deploy to IoT Edge devices. Deployment file. Default: $(System.DefaultWorkingDirectory)/config/deployment.json.
#azureSubscription: # string. Alias: connectedServiceNameARM. Required when action == Deploy to IoT Edge devices. Azure subscription contains IoT Hub.
#iothubname: # string. Required when action == Deploy to IoT Edge devices. IoT Hub name.
#deviceOption: # 'Single Device' | 'Multiple Devices'. Required when action == Deploy to IoT Edge devices. Choose single/multiple device.
#deviceId: # string. Required when deviceOption == Single Device. IoT Edge device ID.
#targetcondition: # string. Required when deviceOption == Multiple Devices. IoT Edge device target condition.
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Generic Container Registry'. Required when action = Push module images. Container registry type. Default: Azure Container Registry.
#dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Required when containerregistrytype = Generic Container Registry. Docker Registry Connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription.
#azureContainerRegistry: # string. Required when containerregistrytype = Azure Container Registry. Azure Container Registry.
#templateFilePath: 'deployment.template.json' # string. Required when action = Build module images || action = Push module images || action = Generate deployment manifest. .template.json file. Default: deployment.template.json.
#defaultPlatform: 'amd64' # 'amd64' | 'windows-amd64' | 'arm32v7'. Required when action = Build module images || action = Push module images || action = Generate deployment manifest. Default platform. Default: amd64.
#fillRegistryCredential: 'true' # 'true' | 'false'. Required when action = Push module images. Add registry credential to deployment manifest. Default: true.
#deploymentManifestOutputPath: '$(System.DefaultWorkingDirectory)/config/deployment.json' # string. Required when action == Generate deployment manifest. Output path. Default: $(System.DefaultWorkingDirectory)/config/deployment.json.
#validateGeneratedDeploymentManifest: 'false' # 'true' | 'false'. Required when action = Generate deployment manifest. Validate the schema of generated deployment manifest. Default: false.
# Advanced
#deploymentid: '$(System.TeamProject)-devops-deployment' # string. Required when action = Deploy to IoT Edge devices. IoT Edge deployment ID. Default: $(System.TeamProject)-devops-deployment.
#priority: '0' # string. Required when action = Deploy to IoT Edge devices. IoT Edge deployment priority. Default: 0.
# Advanced
#bypassModules: # string. Optional. Use when action = Push module images. Bypass module(s).
# Azure IoT Edge v2
# Build and deploy an Azure IoT Edge image.
- task: AzureIoTEdge@2
inputs:
action: 'Build module images' # 'Build module images' | 'Push module images' | 'Generate deployment manifest' | 'Deploy to IoT Edge devices'. Required. Action. Default: Build module images.
#deploymentFilePath: '$(System.DefaultWorkingDirectory)/config/deployment.json' # string. Required when action == Deploy to IoT Edge devices. Deployment file. Default: $(System.DefaultWorkingDirectory)/config/deployment.json.
#azureSubscription: # string. Alias: connectedServiceNameARM. Required when action == Deploy to IoT Edge devices. Azure subscription contains IoT Hub.
#iothubname: # string. Required when action == Deploy to IoT Edge devices. IoT Hub name.
#deviceOption: # 'Single Device' | 'Multiple Devices'. Required when action == Deploy to IoT Edge devices. Choose single/multiple device.
#deviceId: # string. Required when deviceOption == Single Device. IoT Edge device ID.
#targetcondition: # string. Required when deviceOption == Multiple Devices. IoT Edge device target condition.
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Generic Container Registry'. Required when action = Push module images. Container registry type. Default: Azure Container Registry.
#dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Required when containerregistrytype = Generic Container Registry. Docker Registry Connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription.
#azureContainerRegistry: # string. Required when containerregistrytype = Azure Container Registry. Azure Container Registry.
#templateFilePath: 'deployment.template.json' # string. Required when action = Build module images || action = Push module images || action = Generate deployment manifest. .template.json file. Default: deployment.template.json.
#defaultPlatform: 'amd64' # 'amd64' | 'windows-amd64' | 'arm32v7'. Required when action = Build module images || action = Push module images || action = Generate deployment manifest. Default platform. Default: amd64.
#fillRegistryCredential: 'true' # 'true' | 'false'. Required when action = Push module images. Add registry credential to deployment manifest. Default: true.
#deploymentManifestOutputPath: '$(System.DefaultWorkingDirectory)/config/deployment.json' # string. Required when action == Generate deployment manifest. Output path. Default: $(System.DefaultWorkingDirectory)/config/deployment.json.
# Advanced
#deploymentid: '$(System.TeamProject)-devops-deployment' # string. Required when action = Deploy to IoT Edge devices. IoT Edge deployment ID. Default: $(System.TeamProject)-devops-deployment.
#priority: '0' # string. Required when action = Deploy to IoT Edge devices. IoT Edge deployment priority. Default: 0.
# Advanced
#bypassModules: # string. Optional. Use when action = Push module images. Bypass module(s).
输入
action
- 行动
string
. 必需。 允许的值:Build module images
、Push module images
、、Generate deployment manifest
Deploy to IoT Edge devices
。 默认值:Build module images
。
选择 Azure IoT Edge 操作。
Build module images
仅生成模块 (可用于) 检查编译错误。
Push module images
将模块推送到容器注册表。
Deploy to IoT Edge devices
将生成的部署文件部署到 IoT 中心。 (建议将 Deploy
任务放入发布管道中。)
deploymentFilePath
- 部署文件
string
. 当 action == Deploy to IoT Edge devices
时,需要此选项。 默认值:$(System.DefaultWorkingDirectory)/config/deployment.json
。
选择部署 json 文件。
如果此任务位于 中 release pipeline
,则需要在项目中设置部署文件的位置。 (默认值适用于大多数条件。) 如果此任务在生成管道中,则必须指定部署清单输出路径。
azureSubscription
- Azure 订阅包含 IoT 中心
输入别名: connectedServiceNameARM
。 string
. 当 action == Deploy to IoT Edge devices
时,需要此选项。
选择包含IoT 中心的 Azure 订阅。
iothubname
- IoT 中心名称
string
. 当 action == Deploy to IoT Edge devices
时,需要此选项。
选择IoT 中心。
deploymentid
- IoT Edge部署 ID
string
. 当 action = Deploy to IoT Edge devices
时,需要此选项。 默认值:$(System.TeamProject)-devops-deployment
。
输入IoT Edge部署 ID。 如果 ID 已存在,则会重写该 ID。
这最多包含 128 个小写字母和数字,并且允许使用以下字符: -:+%_#*?!(),=@;'
。
有关详细信息,请参阅 Azure IoT Edge 部署。
priority
- IoT Edge部署优先级
string
. 当 action = Deploy to IoT Edge devices
时,需要此选项。 默认值:0
。
priority
将 设置为正整数以解决部署冲突。 当此任务作为多个部署的目标时,设备将使用优先级最高的部署,或者,如果两个部署具有相同优先级,则使用最新的创建时间。
有关详细信息,请参阅 Azure IoT Edge 部署。
deviceOption
- 选择单台/多台设备
string
. 当 action == Deploy to IoT Edge devices
时,需要此选项。 允许的值:Single Device
、Multiple Devices
。
根据标记,选择部署到单个或多台设备。
deviceId
- IoT Edge设备 ID
string
. 当 deviceOption == Single Device
时,需要此选项。
输入IoT Edge device ID
。
targetcondition
- IoT Edge设备目标条件
string
. 当 deviceOption == Multiple Devices
时,需要此选项。
target condition
输入要部署的设备。 请勿使用双引号。 示例: tags.building=9
和 tags.environment='test'
。
有关详细信息,请参阅 Azure IoT Edge 部署。
containerregistrytype
- 容器注册表类型
string
. 当 action = Push module images
时,需要此选项。 允许的值:Azure Container Registry
、Generic Container Registry
。 默认值:Azure Container Registry
。
Container Registry Type
选择 。
Azure Container Registry
适用于 ACR,适用于 Generic Container Registry
泛型注册表(包括 docker 中心)。
dockerRegistryConnection
- Docker 注册表连接
输入别名: dockerRegistryEndpoint
。 string
. 当 containerregistrytype = Generic Container Registry
时,需要此选项。
选择通用 Docker 注册表连接。 这是生成和推送所必需的。
azureSubscriptionEndpoint
- Azure 订阅
string
. 可选。 在 时 containerregistrytype = Azure Container Registry
使用 。
选择 Azure 订阅。
azureContainerRegistry
- Azure 容器注册表
string
. 当 containerregistrytype = Azure Container Registry
时,需要此选项。
选择Azure 容器注册表。
templateFilePath
- .template.json 文件
string
. 当 action = Build module images || action = Push module images || action = Generate deployment manifest
时,需要此选项。 默认值:deployment.template.json
。
Azure IoT Edge解决方案 .template.json
的路径。 此文件定义 Azure IoT Edge解决方案中的模块和路由。 文件名必须以 结尾 .template.json
。
defaultPlatform
- 默认平台
string
. 当 action = Build module images || action = Push module images || action = Generate deployment manifest
时,需要此选项。 允许的值:amd64
、windows-amd64
、、arm32v7
arm64v8
。 默认值:amd64
。
.template.json
在 中,可以将模块平台保留为未指定状态。 对于这些模块,将使用默认平台。
defaultPlatform
- 默认平台
string
. 当 action = Build module images || action = Push module images || action = Generate deployment manifest
时,需要此选项。 允许的值:amd64
、windows-amd64
、arm32v7
。 默认值:amd64
。
.template.json
在 中,可以将模块平台保留为未指定状态。 对于这些模块,将使用默认平台。
fillRegistryCredential
- 将注册表凭据添加到部署清单
string
. 当 action = Push module images
时,需要此选项。 允许的值:true
、false
。 默认值:true
。
将用于将 docker 映像推送到部署清单的注册表凭据。
deploymentManifestOutputPath
- 输出路径
string
. 当 action == Generate deployment manifest
时,需要此选项。 默认值:$(System.DefaultWorkingDirectory)/config/deployment.json
。
生成的部署清单的输出路径。
validateGeneratedDeploymentManifest
- 验证生成的部署清单的架构
string
. 当 action = Generate deployment manifest
时,需要此选项。 允许的值:true
、false
。 默认值:false
。
如果生成的部署清单未通过架构验证,则此步骤失败。 在 JSON 架构存储中搜索Azure IoT Edge deployment
以查找最新架构。
bypassModules
- 绕过模块 ()
string
. 可选。 在 时 action = Push module images
使用 。
选择不需要在 中 .template.json
生成或推送的模块 () ,指定模块名称,并用逗号分隔它们。
示例:如果 中有 SampleModule1
和 ,并且只想生成或推送 SampleModule1
,则将绕过模块设置为 SampleModule2
。SampleModule2
.template.json
如果要在 中 .template.json
生成所有模块,请将此保留为空。
任务控制选项
除了任务输入,所有任务都有控制选项。 有关详细信息,请参阅 控制选项和常见任务属性。
输出变量
此任务定义以下 输出变量,可在下游步骤、作业和阶段中使用。
DEPLOYMENT_FILE_PATH
这是生成的部署文件的路径。
注解
使用此任务快速高效地生成、测试应用程序并将其部署到 Azure IoT Edge。
此任务支持自定义变量。 如果不熟悉如何在管道中使用变量,请参阅 定义变量。
示例
生成模块映像
以下 YAML 示例生成模块映像:
- task: AzureIoTEdge@2
displayName: AzureIoTEdge - Build module images
inputs:
action: Build module images
templateFilePath: deployment.template.json
defaultPlatform: amd64
推送模块映像
以下 YAML 示例推送模块映像:
variables:
azureSubscriptionEndpoint: Contoso
azureContainerRegistry: contoso.azurecr.io
steps:
- task: AzureIoTEdge@2
displayName: AzureIoTEdge - Push module images
inputs:
action: Push module images
containerregistrytype: Azure Container Registry
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureContainerRegistry: {"loginServer":"$(azureContainerRegistry)"}
templateFilePath: deployment.template.json
defaultPlatform: amd64
fillRegistryCredential: true
生成部署清单
以下 YAML 示例基于模板文件创建部署清单:
steps:
- task: AzureIoTEdge@2
displayName: AzureIoTEdge - Generate deployment manifest
inputs:
action: Generate deployment manifest
templateFilePath: deployment.template.json
defaultPlatform: amd64
deploymentManifestOutputPath: $(System.DefaultWorkingDirectory)/config/deployment.json
validateGeneratedDeploymentManifest: false
部署到 IoT Edge 设备
以下 YAML 示例部署模块映像:
steps:
- task: AzureIoTEdge@2
displayName: 'Azure IoT Edge - Deploy to IoT Edge devices'
inputs:
action: 'Deploy to IoT Edge devices'
deploymentFilePath: $(System.DefaultWorkingDirectory)/config/deployment.json
azureSubscription: $(azureSubscriptionEndpoint)
iothubname: iothubname
deploymentid: '$(System.TeamProject)-devops-deployment'
priority: '0'
deviceOption: 'Single Device'
deviceId: deviceId
更多示例
有关如何在 Azure Pipelines 中使用这些操作的分步示例,请参阅以下文章: