Azure IoT Edge image build for AMD64, Arm64v8 in azure devops pipeline with supported Microsoft hosted agents

Dhanavath Vishnu 366 Reputation points
2023-10-10T16:30:57.7366667+00:00

Hi Team,

Hello SatishBoddu-MSFT,

I have scenario, where I am building two types of images of same repo, using Azure IoT Edge Task (AzureIoTEdge@2). Just I am looping this IoT Edge Task for different platform, by replacing defaultPlatform: with two architectures (AMD64, Arm64v8). The build of IoT edge image is getting successful, but the Arm64v8 image build is happening for linux/amd64 platform only, because the Agent we are using in the pipeline is Microsoft hosted agent ubuntu-latest, it seems that by default this is amd64 hosted agent.

As we are using same hosted agent for both images build (AMD64, Arm64v8), this error is we are getting, if we want to run the Microsoft hosted agent for Arm64v8 image build, how should we setup these two host platforms in our pipeline run?

Please help me out on this issue.

Thanks

D. Vishnu

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
598 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,258 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dhanavath Vishnu 366 Reputation points
    2023-10-27T12:14:49.4+00:00

    Hi @LeelaRajeshSayana-MSFT ,

    I have found a solution for this issue, I am updating it here, please do review with your support team, is this standard practice to use these tasks in the azure pipeline. If it is standard practice, the community can use this method for the multiarchitecture IoT Edge image builds.

    The solution which I found is depends on Buildx commands, we need to install it on the Pipeline Agent and run the series of buildx commands. The Filepath should contain the Dockerfile in the repository.

    Thank you.

    D. Vishnu

    #Install BuildX Plug-in using commands
    - task: Bash@3
      displayName: 'Install BuildX Plug-in.'
      inputs:
        targetType: 'inline'
        script: |
          echo "=====> Installation of plugin"
          sudo apt update && sudo apt install -y docker-buildx-plugin
          sudo docker buildx version
          sudo apt list --upgradable
    #Execution Mult-Arch commands for targeted platforms
    
    - task: PowerShell@2
      displayName: 'Execution of Buildx commands'
      inputs:
        targetType: 'inline'
    	script: |
    	  Write-Host "Execution of Buildx Commands"
    	  Set-Location -Path $(System.DefaultWorkingDirectory)/$(FilePath)
    	  $current_directory = pwd
          Write-Host $current_directory
    	  docker run --privileged --rm tonistiigi/binfmt --install all
    	  docker buildx create --name multiarchbuilder
    	  docker buildx use multiarchbuilder
    	  docker buildx ls
    	  docker buildx inspect --bootstrap
    	  docker buildx build --platform linux/amd64,linux/arm64 -t imagerepoaddr:tags--push .
    	  Write-Host "Ended execution of Buildx Commands."
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.