Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to run tasks rights away with azurerm_container_registry_task #15095

Closed
tlfzhylj opened this issue Jan 24, 2022 · 9 comments · Fixed by #15120
Closed

Make it possible to run tasks rights away with azurerm_container_registry_task #15095

tlfzhylj opened this issue Jan 24, 2022 · 9 comments · Fixed by #15120

Comments

@tlfzhylj
Copy link

tlfzhylj commented Jan 24, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

When using azurerm_container_registry_task I would like these to be supported:
A) Point to a Dockerfile, for example in a git repo, and run the build right away.
B) Run a build right away, where I'm pointing to a Dockerfile in my Terraform project directory, together with my tf files.

New or Affected Resource(s)

  • azurerm_container_registry_task

Potential Terraform Configuration

resource "azurerm_container_registry_task" "example" {
  name                  = "Example"
  container_registry_id = azurerm_container_registry.example.id


  platform {
    os           = "Linux"
    architecture = "amd64"
  }

  docker_step {
    dockerfile_path      = "Dockerfile"
    context_path         = "https://dev.azure.com/<org>/<project>/_git/<repo>"
    context_access_token = "<PAT>"
    image_names          = ["image:latest"]

    # Something like this could be added
    # Terraform task should not finish before the build is finished
    trigger_onetime_run = true
  }

  # And also be able to add the source_trigger as well for future updates
  source_trigger {
    name           = "newcommits"
    events         = ["commit"]
    repository_url = "https://dev.azure.com/<org>/<project>/_git/<repo>"
    source_type    = "VisualStudioTeamService"
    authentication {
      token      = "<PAT>"
      token_type = "PAT"
    }
  }
}
@tombuildsstuff
Copy link
Contributor

hi @tlfzhylj

Thanks for opening this issue.

This forum is intended to be used for feature enhancements and bugs in the Azure Provider - so that we can keep this forum focused on that we instead ask that broader questions are raised on the Community Discuss forum.

Thanks!

@tlfzhylj
Copy link
Author

Thanks for your answer.

What I can find out what I'm asking isn't possible, so if the issue can be open and labeled enhancement I think that would be correct.

I can rewrite the title and description a bit to make it more clear that it is a feature request.

@tlfzhylj tlfzhylj changed the title Possible to make azurerm_container_registry_task run the task right away? Make it possible to run tasks rights away with azurerm_container_registry_task Jan 25, 2022
@tlfzhylj
Copy link
Author

If this one doesn't get opened again, I asked in the community forum as advised: https://discuss.hashicorp.com/t/azure-container-registry-task-possible-to-run-the-task-right-away/34739

@tombuildsstuff
Copy link
Contributor

@tlfzhylj from what I can see this isn't supported in the API right now - https://docs.microsoft.com/en-us/rest/api/containerregistry/tasks - so (unless your aware of another API) I don't believe this is possible at this time. As such I think this maybe a Feature Request for Microsoft here, since there would need to be a means of triggering the task one-time (and retrieving the status of it) to be able to be able to achieve this - so in lieu of an API being available I'd recommend opening an issue on the Azure Rest API Specs repository where someone from the Service Team should be able to take a look.

@magodo
Copy link
Collaborator

magodo commented Jan 26, 2022

@tombuildsstuff I've looked into this issue and submit a PR for it. The API actually resides in: https://docs.microsoft.com/en-us/rest/api/containerregistry/registries%20(tasks)/schedule-run instead.

@tombuildsstuff
Copy link
Contributor

@magodo oh nice find - thanks :)

@radoslawcz
Copy link

Hello, any news on this?

@magodo magodo reopened this Feb 19, 2022
@piizei
Copy link

piizei commented May 12, 2022

would be great to get this working, but meanwhile I'm using this as a workaround:

resource "azapi_resource" "run_acr_task" {
  name = azurerm_container_registry.acr.name 
  location = var.location
  parent_id = azurerm_container_registry.acr.id
  type = "Microsoft.ContainerRegistry/registries/taskRuns@2019-06-01-preview"
  body = jsonencode({
    properties = {
       runRequest = {
         type = "DockerBuildRequest"
         sourceLocation = "https://github.com/Azure-Samples/aci-helloworld.git#master"
         dockerFilePath = "Dockerfile"
         platform = {
           os = "Linux"
          }
         imageNames = ["helloworld:{{.Run.ID}}", "helloworld:latest"]
       }
    }
  })
  ignore_missing_property = true
}

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants