AzureIoTEdge@2 — zadanie usługi Azure IoT Edge w wersji 2

To zadanie służy do szybkiego i wydajnego kompilowania obrazów w usłudze Azure IoT Edge.

To zadanie obsługuje zmienne niestandardowe. Jeśli nie znasz sposobu używania zmiennych w potokach, zobacz definiowanie zmiennych.

Składnia

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

Dane wejściowe

action - Działania
string. Wymagane. Dozwolone wartości: Build module images, Push module images, Generate deployment manifest, Deploy to IoT Edge devices. Wartość domyślna: Build module images.

Wybiera akcję IoT Edge platformy Azure.

Build module images kompiluje tylko moduły (można ich używać do sprawdzania błędów kompilacji).

Push module images wypycha moduły do rejestru kontenerów.

Deploy to IoT Edge deviceswdraża wygenerowany plik wdrożenia w IoT Hub. (Zalecamy umieszczenie Deploy zadania w potoku wydania).


deploymentFilePath - Plik wdrożenia
string. Wymagane, gdy action == Deploy to IoT Edge devices. Wartość domyślna: $(System.DefaultWorkingDirectory)/config/deployment.json.

Wybiera plik json wdrożenia. Jeśli to zadanie znajduje się w release pipelineelemecie , należy ustawić lokalizację pliku wdrożenia w artefaktie. (Wartość domyślna działa w przypadku większości warunków). Jeśli to zadanie znajduje się w potoku kompilacji, musisz określić ścieżkę wyjściową manifestu wdrożenia.


azureSubscription - Subskrypcja platformy Azure zawiera IoT Hub
Alias wejściowy: connectedServiceNameARM. string. Wymagane, gdy action == Deploy to IoT Edge devices.

Wybiera subskrypcję platformy Azure zawierającą IoT Hub.


iothubname - nazwa IoT Hub
string. Wymagane, gdy action == Deploy to IoT Edge devices.

Wybiera IoT Hub.


deploymentid - identyfikator wdrożenia IoT Edge
string. Wymagane, gdy action = Deploy to IoT Edge devices. Wartość domyślna: $(System.TeamProject)-devops-deployment.

Wprowadza identyfikator wdrożenia IoT Edge. Jeśli identyfikator już istnieje, zostanie on zastąpiony. Może to zawierać maksymalnie 128 małych liter i cyfr, a następujące znaki są dozwolone: -:+%_#*?!(),=@;'. Aby uzyskać więcej informacji, zobacz Wdrażanie usługi Azure IoT Edge.


priority - priorytet wdrożenia IoT Edge
string. Wymagane, gdy action = Deploy to IoT Edge devices. Wartość domyślna: 0.

priority Ustawia wartość na dodatnią liczbę całkowitą, aby rozwiązać konflikty wdrożenia. Gdy to zadanie jest objęte wieloma wdrożeniami, urządzenie będzie używać tego z najwyższym priorytetem lub w przypadku dwóch wdrożeń o tym samym priorytetzie, najpóźniejszego czasu utworzenia. Aby uzyskać więcej informacji, zobacz Wdrażanie usługi Azure IoT Edge.


deviceOption - Wybieranie pojedynczego/wielokrotnego urządzenia
string. Wymagane, gdy action == Deploy to IoT Edge devices. Dozwolone wartości: Single Device, Multiple Devices.

Zgodnie z tagami wybiera wdrożenie na jednym lub wielu urządzeniach.


deviceId - identyfikator urządzenia IoT Edge
string. Wymagane, gdy deviceOption == Single Device.

Wprowadza IoT Edge device ID.


targetcondition - warunek docelowy urządzenia IoT Edge
string. Wymagane, gdy deviceOption == Multiple Devices.

target condition Dane wejściowe urządzeń, które chcesz wdrożyć. Nie używaj cudzysłowów podwójnych. Przykład: tags.building=9 i tags.environment='test'. Aby uzyskać więcej informacji, zobacz Wdrażanie usługi Azure IoT Edge.


containerregistrytype - Typ rejestru kontenerów
string. Wymagane, gdy action = Push module images. Dozwolone wartości: Azure Container Registry, Generic Container Registry. Wartość domyślna: Azure Container Registry.

Wybiera element Container Registry Type. Azure Container Registry jest przeznaczony dla usługi ACR i Generic Container Registry jest przeznaczony dla rejestrów ogólnych, w tym docker hub.


dockerRegistryConnection - Połączenie rejestru platformy Docker
Alias wejściowy: dockerRegistryEndpoint. string. Wymagane, gdy containerregistrytype = Generic Container Registry.

Wybiera ogólne połączenie rejestru platformy Docker. Jest to wymagane w przypadku kompilacji i wypychania.


azureSubscriptionEndpoint - Subskrypcja platformy Azure
string. Opcjonalny. Użyj polecenia , gdy containerregistrytype = Azure Container Registry.

Wybiera subskrypcję platformy Azure.


azureContainerRegistry - Azure Container Registry
string. Wymagane, gdy containerregistrytype = Azure Container Registry.

Wybiera Azure Container Registry.


templateFilePath - Plik .template.json
string. Wymagane, gdy action = Build module images || action = Push module images || action = Generate deployment manifest. Wartość domyślna: deployment.template.json.

Ścieżka rozwiązania .template.jsonusługi Azure IoT Edge . Ten plik definiuje moduły i trasy w rozwiązaniu usługi Azure IoT Edge. Nazwa pliku musi kończyć się ciągiem .template.json.


defaultPlatform - Domyślna platforma
string. Wymagane, gdy action = Build module images || action = Push module images || action = Generate deployment manifest. Dozwolone wartości: amd64, windows-amd64, arm32v7, arm64v8. Wartość domyślna: amd64.

W programie .template.jsonmożesz pozostawić platformę modułów nieokreśloną. W przypadku tych modułów zostanie użyta domyślna platforma.


defaultPlatform - Domyślna platforma
string. Wymagane, gdy action = Build module images || action = Push module images || action = Generate deployment manifest. Dozwolone wartości: amd64, windows-amd64, arm32v7. Wartość domyślna: amd64.

W programie .template.jsonmożesz pozostawić platformę modułów nieokreśloną. W przypadku tych modułów zostanie użyta domyślna platforma.


fillRegistryCredential - Dodawanie poświadczeń rejestru do manifestu wdrożenia
string. Wymagane, gdy action = Push module images. Dozwolone wartości: true, false. Wartość domyślna: true.

Dodaje poświadczenie rejestru do wypychania obrazów platformy Docker do manifestu wdrożenia.


deploymentManifestOutputPath - Ścieżka danych wyjściowych
string. Wymagane, gdy action == Generate deployment manifest. Wartość domyślna: $(System.DefaultWorkingDirectory)/config/deployment.json.

Ścieżka wyjściowa wygenerowanego manifestu wdrożenia.


validateGeneratedDeploymentManifest - Weryfikowanie schematu wygenerowanego manifestu wdrożenia
string. Wymagane, gdy action = Generate deployment manifest. Dozwolone wartości: true, false. Wartość domyślna: false.

Ten krok nie powiedzie się, jeśli wygenerowany manifest wdrożenia nie przejdzie walidacji schematu. Wyszukaj Azure IoT Edge deployment w magazynie schematów JSON , aby znaleźć najnowszy schemat.


bypassModules - Pomiń moduły
string. Opcjonalny. Użyj polecenia , gdy action = Push module images.

Wybiera moduły, których nie trzeba kompilować ani wypychać, .template.jsonokreśla nazwy modułów i oddziela je przecinkami. Przykład: jeśli masz SampleModule1 elementy i w .template.json usłudze i SampleModule2 chcesz tylko skompilować lub wypchnąć SampleModule1, należy ustawić moduły obejścia jako SampleModule2. Pozostaw to pole puste, jeśli chcesz skompilować wszystkie moduły w pliku .template.json.


Opcje sterowania zadania

Wszystkie zadania mają opcje sterowania oprócz danych wejściowych zadań. Aby uzyskać więcej informacji, zobacz Opcje sterowania i typowe właściwości zadań.

Zmienne wyjściowe

To zadanie definiuje następujące zmienne wyjściowe, które można używać w krokach podrzędnych, zadaniach i etapach.

DEPLOYMENT_FILE_PATH
Jest to ścieżka wygenerowanego pliku wdrożenia.

Uwagi

To zadanie służy do szybkiego i wydajnego kompilowania, testowania i wdrażania aplikacji w usłudze Azure IoT Edge.

To zadanie obsługuje zmienne niestandardowe. Jeśli nie znasz sposobu używania zmiennych w potokach, zobacz Definiowanie zmiennych.

Przykłady

Kompilowanie obrazów modułów

Poniższy przykład YAML tworzy obrazy modułów:

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

Wypychanie obrazów modułów

Poniższy przykład YAML wypycha obrazy modułów:

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

Generowanie manifestu wdrożenia

Poniższy przykład YAML tworzy manifest wdrożenia na podstawie pliku szablonu:

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

Wdrażanie na urządzeniach usługi IoT Edge

Poniższy przykład YAML wdraża obrazy modułów:

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

Więcej przykładów

Aby zapoznać się z przykładami krok po kroku dotyczącymi używania tych akcji w usłudze Azure Pipelines, zobacz następujące artykuły:

Wymagania

Wymaganie Opis
Typy potoków YAML, klasyczna kompilacja, wersja klasyczna
Działa w Agent, DeploymentGroup
Wymagania Brak
Możliwości To zadanie nie spełnia żadnych wymagań dotyczących kolejnych zadań w zadaniu.
Ograniczenia poleceń Dowolne
Zmienne ustawialne Dowolne
Wersja agenta Wszystkie obsługiwane wersje agenta.
Kategoria zadania Kompilacja