az acr task run equivalent in bicep

Giovani Decusati 5 Reputation points
2024-03-19T12:33:49.37+00:00

Hi Team,

I have an Azure DevOps Git repo contenting a docker file to build a docker image of a self-host agent.

I've deployed a container registry instance via Bicep. I want to build this docker image using Bicep. I've looked into some samples where creating a "build-task" into the container registry instance using Bicep is possible, but I don't know how to trigger it.

The equivalent command in CLI:

az acr task create --registry mycrinstance --name taskhelloworld --image helloworld:latest --context "https://username@dev.azure.com/username/projectname/_git/reponame#main:foldername" --file "Dockerfile" --git-access-token "PAT" --platform linux/amd64

az acr task run --registry mycrinstance --name taskhelloworld

How can I achieve this using Bicep? Any guess?

References:

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
405 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Stanislav Zhelyazkov 21,506 Reputation points MVP
    2024-03-19T13:11:59.5933333+00:00

    Hi,

    Triggering a task for container registry via bicep is not possible. The trigger action is basically not a state but operation/action. It is the same like starting or stopping a VM. Bicep simply does not supports operations. If you want to trigger it you could overcome this by using deployment script. The deployment script is a resource that can be deployed by Bicep that basically allows you to do operations by executing Az CLI or Azure PS commands.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments