Bagikan melalui


AzureIoTEdge@2 - Tugas Azure IoT Edge v2

Gunakan tugas ini untuk membangun dan menyebarkan gambar dengan cepat dan efisien ke Azure IoT Edge.

Tugas ini mendukung variabel kustom. Jika Anda tidak terbiasa dengan cara menggunakan variabel di Alur, lihat menentukan variabel.

Sintaks

# 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).

Input

action - Tindakan
string. Wajib diisi. Nilai yang diizinkan: Build module images, Push module images, Generate deployment manifest, Deploy to IoT Edge devices. Nilai default: Build module images.

Memilih tindakan Azure IoT Edge.

Build module images hanya membangun modul (Anda dapat menggunakannya untuk memeriksa kesalahan kompilasi).

Push module images mendorong modul ke registri kontainer.

Deploy to IoT Edge devicesmenyebarkan file penyebaran yang dihasilkan ke IoT Hub. (Sebaiknya letakkan Deploy tugas dalam alur rilis.)


deploymentFilePath - File penyebaran
string. Diperlukan saat action == Deploy to IoT Edge devices. Nilai default: $(System.DefaultWorkingDirectory)/config/deployment.json.

Memilih file json penyebaran. Jika tugas ini ada di release pipeline, Anda perlu mengatur lokasi file penyebaran dalam artefak. (Nilai default berfungsi untuk sebagian besar kondisi.) Jika tugas ini berada dalam alur build, Anda harus menentukan jalur output manifes penyebaran.


azureSubscription - Langganan Azure berisi IoT Hub
Alias input: connectedServiceNameARM. string. Diperlukan saat action == Deploy to IoT Edge devices.

Memilih langganan Azure yang berisi IoT Hub.


iothubname - nama IoT Hub
string. Diperlukan saat action == Deploy to IoT Edge devices.

Memilih IoT Hub.


deploymentid - ID penyebaran IoT Edge
string. Diperlukan saat action = Deploy to IoT Edge devices. Nilai default: $(System.TeamProject)-devops-deployment.

Memasukkan ID Penyebaran IoT Edge. Jika ID sudah ada, ID akan ditimpa. Ini memiliki hingga 128 huruf kecil dan angka, dan karakter berikut diperbolehkan: -:+%_#*?!(),=@;'. Untuk informasi selengkapnya, lihat Penyebaran Azure IoT Edge.


priority - prioritas penyebaran IoT Edge
string. Diperlukan saat action = Deploy to IoT Edge devices. Nilai default: 0.

Mengatur ke bilangan priority bulat positif untuk mengatasi konflik penyebaran. Ketika tugas ini ditargetkan oleh beberapa penyebaran, perangkat akan menggunakannya dengan prioritas tertinggi atau, dalam kasus dua penyebaran dengan prioritas yang sama, waktu pembuatan terbaru. Untuk informasi selengkapnya, lihat Penyebaran Azure IoT Edge.


deviceOption - Pilih satu/beberapa perangkat
string. Diperlukan saat action == Deploy to IoT Edge devices. Nilai yang diizinkan: Single Device, Multiple Devices.

Menurut tag, memilih untuk menyebarkan ke satu atau beberapa perangkat.


deviceId - ID perangkat IoT Edge
string. Diperlukan saat deviceOption == Single Device.

Memasukkan IoT Edge device ID.


targetcondition - IoT Edge kondisi target perangkat
string. Diperlukan saat deviceOption == Multiple Devices.

Memasukkan perangkat yang target condition ingin Anda sebarkan. Jangan gunakan tanda kutip ganda. Contoh: tags.building=9 dan tags.environment='test'. Untuk informasi selengkapnya, lihat Penyebaran Azure IoT Edge.


containerregistrytype - Jenis registri kontainer
string. Diperlukan saat action = Push module images. Nilai yang diizinkan: Azure Container Registry, Generic Container Registry. Nilai default: Azure Container Registry.

Container Registry TypeMemilih . Azure Container Registry adalah untuk ACR, dan Generic Container Registry untuk registri generik termasuk hub docker.


dockerRegistryConnection - Koneksi Docker Registry
Alias input: dockerRegistryEndpoint. string. Diperlukan saat containerregistrytype = Generic Container Registry.

Memilih koneksi registri Docker generik. Ini diperlukan untuk membangun dan mendorong.


azureSubscriptionEndpoint - Langganan Azure
string. Opsional. Gunakan saat containerregistrytype = Azure Container Registry.

Memilih langganan Azure.


azureContainerRegistry - Azure Container Registry
string. Diperlukan saat containerregistrytype = Azure Container Registry.

Memilih Azure Container Registry.


templateFilePath - File .template.json
string. Diperlukan saat action = Build module images || action = Push module images || action = Generate deployment manifest. Nilai default: deployment.template.json.

Jalur solusi .template.jsonAzure IoT Edge . File ini menentukan modul dan rute dalam solusi Azure IoT Edge. Nama file harus diakhir dengan .template.json.


defaultPlatform - Platform default
string. Diperlukan saat action = Build module images || action = Push module images || action = Generate deployment manifest. Nilai yang diizinkan: amd64, windows-amd64, arm32v7, arm64v8. Nilai default: amd64.

.template.jsonDi , Anda dapat membiarkan platform modul tidak ditentukan. Untuk modul ini, platform default akan digunakan.


defaultPlatform - Platform default
string. Diperlukan saat action = Build module images || action = Push module images || action = Generate deployment manifest. Nilai yang diizinkan: amd64, windows-amd64, dan arm32v7. Nilai default: amd64.

.template.jsonDi , Anda dapat membiarkan platform modul tidak ditentukan. Untuk modul ini, platform default akan digunakan.


fillRegistryCredential - Menambahkan kredensial registri ke manifes penyebaran
string. Diperlukan saat action = Push module images. Nilai yang diizinkan: true, false. Nilai default: true.

Menambahkan kredensial registri untuk mendorong gambar docker ke manifes penyebaran.


deploymentManifestOutputPath - Jalur output
string. Diperlukan saat action == Generate deployment manifest. Nilai default: $(System.DefaultWorkingDirectory)/config/deployment.json.

Jalur output dari manifes penyebaran yang dihasilkan.


validateGeneratedDeploymentManifest - Memvalidasi skema manifes penyebaran yang dihasilkan
string. Diperlukan saat action = Generate deployment manifest. Nilai yang diizinkan: true, false. Nilai default: false.

Gagalkan langkah ini jika manifes penyebaran yang dihasilkan tidak lulus validasi skema. Cari Azure IoT Edge deployment di Penyimpanan Skema JSON untuk menemukan skema terbaru.


bypassModules - Melewati modul
string. Pilihan. Gunakan saat action = Push module images.

Memilih modul yang tidak perlu Anda buat atau dorong di .template.json, menentukan nama modul, dan memisahkannya dengan koma. Contoh: jika Anda memiliki SampleModule1 dan SampleModule2 di dan .template.json Anda hanya ingin membangun atau mendorong SampleModule1, maka Anda mengatur modul bypass sebagai SampleModule2. Biarkan kosong ini jika Anda ingin membangun semua modul di .template.json.


Opsi kontrol tugas

Semua tugas memiliki opsi kontrol selain input tugas mereka. Untuk informasi selengkapnya, lihat Opsi kontrol dan properti tugas umum.

Variabel output

Tugas ini mendefinisikan variabel output berikut, yang dapat Anda konsumsi dalam langkah-langkah hilir, pekerjaan, dan tahapan.

DEPLOYMENT_FILE_PATH
Ini adalah jalur file penyebaran yang dihasilkan.

Keterangan

Gunakan tugas ini untuk membangun, menguji, dan menyebarkan aplikasi dengan cepat dan efisien ke Azure IoT Edge.

Tugas ini mendukung variabel kustom. Jika Anda tidak terbiasa dengan cara menggunakan variabel di Alur, lihat Menentukan variabel.

Contoh

Gambar modul build

Contoh YAML berikut membuat gambar modul:

- task: AzureIoTEdge@2
  displayName: AzureIoTEdge - Build module images
  inputs:
    action: Build module images
    templateFilePath: deployment.template.json
    defaultPlatform: amd64  

Gambar modul dorong

Contoh YAML berikut mendorong gambar modul:

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

Membuat manifes penyebaran

Contoh YAML berikut membuat manifes penyebaran berdasarkan file templat:

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

Menyebarkan ke perangkat IoT Edge

Contoh YAML berikut menyebarkan gambar modul:

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

Contoh lainnya

Untuk contoh langkah demi langkah tentang cara menggunakan tindakan ini di Azure Pipelines, lihat artikel berikut ini:

Persyaratan

Persyaratan Deskripsi
Jenis alur YAML, Build klasik, Rilis klasik
Berjalan pada Agen, DeploymentGroup
Permintaan Tidak ada
Kemampuan Tugas ini tidak memenuhi tuntutan apa pun untuk tugas berikutnya dalam pekerjaan.
Pembatasan perintah Apa pun
Variabel yang dapat diatur Apa pun
Versi agen Semua versi agen yang didukung.
Kategori tugas Build