共用方式為


AzureIoTEdge@2 - Azure IoT Edge v2 工作

使用此工作快速且有效率地建置映射,並將其部署至 Azure IoT Edge。

這項工作支援自訂變數。 如果您不熟悉如何在 Pipelines 中使用變數,請參閱 定義變數

Syntax

# 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 imagesGenerate deployment manifestDeploy 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 中樞
輸入別名: connectedServiceNameARMstring. 當 action == Deploy to IoT Edge devices 時為必要。

選取包含IoT 中樞的 Azure 訂用帳戶。


iothubname - IoT 中樞名稱
string. 當 action == Deploy to IoT Edge devices 時為必要。

選取IoT 中樞。


deploymentid - IoT Edge部署識別碼
string. 當 action = Deploy to IoT Edge devices 時為必要。 預設值:$(System.TeamProject)-devops-deployment

輸入IoT Edge部署識別碼。 如果識別碼已經存在,則會覆寫它。 這最多有 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 DeviceMultiple Devices

根據標籤,選擇部署至單一或多個裝置。


deviceId - IoT Edge裝置識別碼
string. 當 deviceOption == Single Device 時為必要。

輸入 IoT Edge device ID


targetcondition - IoT Edge裝置目標條件
string. 當 deviceOption == Multiple Devices 時為必要。

target condition輸入您想要部署的裝置。 請勿使用雙引號。 範例: tags.building=9tags.environment='test' 。 如需詳細資訊,請參閱Azure IoT Edge部署


containerregistrytype - 容器登錄類型
string. 當 action = Push module images 時為必要。 允許值:Azure Container RegistryGeneric Container Registry。 預設值:Azure Container Registry

Container Registry Type選取 。 Azure Container Registry 適用于 ACR,而且 Generic Container Registry 適用于包含 Docker 中樞的泛型登錄。


dockerRegistryConnection - Docker 登錄連線
輸入別名: dockerRegistryEndpointstring. 當 containerregistrytype = Generic Container Registry 時為必要。

選取一般 Docker 登錄連線。 這是建置和推送的必要專案。


azureSubscriptionEndpoint - Azure 訂用帳戶
string. 選擇性。 使用 時 containerregistrytype = Azure Container Registry

選取 Azure 訂用帳戶。


azureContainerRegistry - Azure Container Registry
string. 當 containerregistrytype = Azure Container Registry 時為必要。

選取Azure Container Registry。


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-amd64arm32v7arm64v8 。 預設值:amd64

.template.json在您的 中,您可以將模組平臺保持未指定。 針對這些模組,將會使用預設平臺。


defaultPlatform - 預設平臺
string. 當 action = Build module images || action = Push module images || action = Generate deployment manifest 時為必要。 允許值:amd64windows-amd64arm32v7。 預設值:amd64

.template.json在您的 中,您可以將模組平臺保持未指定。 針對這些模組,將會使用預設平臺。


fillRegistryCredential - 將登錄認證新增至部署資訊清單
string. 當 action = Push module images 時為必要。 允許值:truefalse。 預設值:true

將將 Docker 映射推送至部署資訊清單的登錄認證。


deploymentManifestOutputPath - 輸出路徑
string. 當 action == Generate deployment manifest 時為必要。 預設值:$(System.DefaultWorkingDirectory)/config/deployment.json

所產生部署資訊清單的輸出路徑。


validateGeneratedDeploymentManifest - 驗證所產生部署資訊清單的架構
string. 當 action = Generate deployment manifest 時為必要。 允許值:truefalse。 預設值:false

如果產生的部署資訊清單未通過架構驗證,請失敗此步驟。 在JSON 架構存放區中搜尋 Azure IoT Edge deployment 以尋找最新的架構。


bypassModules - 略過模組 (s)
string. 選擇性。 使用 時機 action = Push module images

選取您不需要在 中 .template.json 建置或推送的模組 () ,指定模組名稱,並以逗號分隔。 範例:如果您有 SampleModule1 和 , SampleModule2.template.json 而且只想要建置或推送 SampleModule1 ,則會將略過模組設定為 SampleModule2 。 如果您想要在 中 .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 中使用這些動作的逐步範例,請參閱下列文章:

規格需求

需求 描述
管線類型 YAML、傳統組建、傳統版本
執行于 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
Settable 變數 任何
代理程式版本 所有支援的代理程式版本。
工作類別 建置