Dela via


AzureIoTEdge@2 – Azure IoT Edge v2-uppgift

Använd den här uppgiften för att skapa och distribuera avbildningar snabbt och effektivt till Azure IoT Edge.

Den här uppgiften stöder anpassade variabler. Om du inte är bekant med hur du använder variabler i Pipelines kan du läsa definiera variabler.

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

Ingångar

action - åtgärd
string. Obligatoriskt. Tillåtna värden: Build module images, Push module images, Generate deployment manifest, Deploy to IoT Edge devices. Standardvärde: Build module images.

Väljer en Azure IoT Edge-åtgärd.

Build module images bygger bara moduler (du kan använda den för att kontrollera kompileringsfel).

Push module images push-överför moduler till containerregistret.

Deploy to IoT Edge devices distribuerar den genererade distributionsfilen till IoT Hub. (Vi rekommenderar att du placerar Deploy uppgiften i versionspipelinen.)


deploymentFilePath - Distributionsfil
string. Krävs när action == Deploy to IoT Edge devices. Standardvärde: $(System.DefaultWorkingDirectory)/config/deployment.json.

Väljer json-filen för distribution. Om den här uppgiften finns i release pipelinemåste du ange platsen för distributionsfilen i artefakt. (Standardvärdet fungerar för de flesta villkor.) Om den här uppgiften finns i en bygg-pipeline måste du ange utdatasökvägen för distributionsmanifestet.


azureSubscription - Azure-prenumeration innehåller IoT Hub-
Indataalias: connectedServiceNameARM. string. Krävs när action == Deploy to IoT Edge devices.

Väljer en Azure-prenumeration som innehåller IoT Hub.


iothubname - IoT Hub-namn
string. Krävs när action == Deploy to IoT Edge devices.

Väljer IoT Hub.


deploymentid - IoT Edge-distributions-ID
string. Krävs när action = Deploy to IoT Edge devices. Standardvärde: $(System.TeamProject)-devops-deployment.

Anger IoT Edge-distributions-ID:t. Om ID:t redan finns kommer det att åsidosättas. Detta har upp till 128 gemener och siffror och följande tecken tillåts: -:+%_#*?!(),=@;'. Mer information finns i Azure IoT Edge-distribution.


priority - IoT Edge-distributionsprioritet
string. Krävs när action = Deploy to IoT Edge devices. Standardvärde: 0.

Anger priority till ett positivt heltal för att lösa distributionskonflikter. När den här uppgiften är riktad mot flera distributioner använder en enhet den med högsta prioritet eller, om det gäller två distributioner med samma prioritet, den senaste tiden för skapande. Mer information finns i Azure IoT Edge-distribution.


deviceOption - Välj en eller flera enheter
string. Krävs när action == Deploy to IoT Edge devices. Tillåtna värden: Single Device, Multiple Devices.

Enligt taggar väljer du att distribuera till en eller flera enheter.


deviceId - IoT Edge-enhets-ID
string. Krävs när deviceOption == Single Device.

Anger IoT Edge-device ID.


targetcondition - IoT Edge-enhetens målvillkor
string. Krävs när deviceOption == Multiple Devices.

Anger target condition av enheter som du vill distribuera. Använd inte dubbla citattecken. Exempel: tags.building=9 och tags.environment='test'. Mer information finns i Azure IoT Edge-distribution.


containerregistrytype - containerregistertyp
string. Krävs när action = Push module images. Tillåtna värden: Azure Container Registry, Generic Container Registry. Standardvärde: Azure Container Registry.

Väljer en Container Registry Type. Azure Container Registry är för ACR och Generic Container Registry gäller för generiska register, inklusive Docker Hub.


dockerRegistryConnection - Docker-registeranslutning
Indataalias: dockerRegistryEndpoint. string. Krävs när containerregistrytype = Generic Container Registry.

Väljer en allmän Docker-registeranslutning. Detta krävs för att skapa och push-överföra.


azureSubscriptionEndpoint - Azure-prenumeration
string. Valfritt. Använd när containerregistrytype = Azure Container Registry.

Väljer en Azure-prenumeration.


azureContainerRegistry - Azure Container Registry
string. Krävs när containerregistrytype = Azure Container Registry.

Anger ett Azure Container Registry. Det här värdet ska anges i json format.

azureContainerRegistry: '{"loginServer": "contoso.azurecr.io"}

templateFilePath - .template.json fil
string. Krävs när action = Build module images || action = Push module images || action = Generate deployment manifest. Standardvärde: deployment.template.json.

Sökvägen till Azure IoT Edge-lösningen .template.json. Den här filen definierar modulerna och vägarna i Azure IoT Edge-lösningen. Filnamnet måste sluta med .template.json.


defaultPlatform - Standardplattform
string. Krävs när action = Build module images || action = Push module images || action = Generate deployment manifest. Tillåtna värden: amd64, windows-amd64, arm32v7, arm64v8. Standardvärde: amd64.

I din .template.jsonkan du lämna modulplattformen ospecificerad. För dessa moduler används standardplattformen.


defaultPlatform - Standardplattform
string. Krävs när action = Build module images || action = Push module images || action = Generate deployment manifest. Tillåtna värden: amd64, windows-amd64, arm32v7. Standardvärde: amd64.

I din .template.jsonkan du lämna modulplattformen ospecificerad. För dessa moduler används standardplattformen.


fillRegistryCredential - Lägg till registerautentiseringsuppgifter i distributionsmanifestet
string. Krävs när action = Push module images. Tillåtna värden: true, false. Standardvärde: true.

Lägger till registerautentiseringsuppgifterna för push-överföring av Docker-avbildningar till distributionsmanifestet.


deploymentManifestOutputPath - utdatasökväg
string. Krävs när action == Generate deployment manifest. Standardvärde: $(System.DefaultWorkingDirectory)/config/deployment.json.

Utdatasökvägen för det genererade distributionsmanifestet.


validateGeneratedDeploymentManifest - Verifiera schemat för det genererade distributionsmanifestet
string. Krävs när action = Generate deployment manifest. Tillåtna värden: true, false. Standardvärde: false.

Det här steget misslyckas om det genererade distributionsmanifestet inte klarar schemaverifieringen. Sök Azure IoT Edge deployment i JSON Schema Store för att hitta det senaste schemat.


bypassModules - Kringgå moduler
string. Valfritt. Använd när action = Push module images.

Väljer de moduler som du inte behöver skapa eller push-överföra .template.json, anger modulnamnen och separerar dem med kommatecken. Exempel: Om du har SampleModule1 och SampleModule2 i .template.json och bara vill skapa eller push-överföra SampleModule1anger du bypass-modulerna som SampleModule2. Lämna detta tomt om du vill skapa alla moduler i .template.json.


Kontrollalternativ för aktivitet

Alla aktiviteter har kontrollalternativ utöver sina aktivitetsindata. Mer information finns i Kontrollalternativ och vanliga uppgiftsegenskaper.

Utdatavariabler

Den här uppgiften definierar följande utdatavariabler, som du kan använda i underordnade steg, jobb och steg.

DEPLOYMENT_FILE_PATH
Det här är sökvägen till den genererade distributionsfilen.

Anmärkningar

Använd den här uppgiften för att skapa, testa och distribuera program snabbt och effektivt till Azure IoT Edge.

Den här uppgiften stöder anpassade variabler. Om du inte är bekant med hur du använder variabler i Pipelines kan du läsa Definiera variabler.

Exempel

Skapa modulbilder

I följande YAML-exempel skapas modulbilder:

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

Push-modulbilder

I följande YAML-exempel skickas modulbilder:

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

Generera distributionsmanifest

I följande YAML-exempel skapas ett distributionsmanifest baserat på mallfilen:

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

Distribuera till IoT Edge-enheter

Följande YAML-exempel distribuerar modulbilder:

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

Fler exempel

Stegvisa exempel på hur du använder dessa åtgärder i Azure Pipelines finns i följande artiklar:

Krav

Krav Beskrivning
Pipelinetyper YAML, klassisk version, klassisk version
Körs på Agent, DeploymentGroup
kräver Ingen
funktioner Den här aktiviteten uppfyller inte några krav på efterföljande uppgifter i jobbet.
Kommandobegränsningar Vilken som helst
variabler som kan Vilken som helst
Agentversion Alla agentversioner som stöds.
Aktivitetskategori Skapa