3

Using hashicorp/azurerm provider I want to set up a webhook that would trigger a deployment.

I have a web app that loads the newest Docker image on restart. However, I need a scmUri of the resource to setup the webhook:

resource "azurerm_linux_web_app" "web" {
  app_settings = {
    DOCKER_REGISTRY_SERVER_URL      = url
    DOCKER_REGISTRY_SERVER_USERNAME = data.azurerm_key_vault_secret.acr-service-principal-id.value
    DOCKER_REGISTRY_SERVER_PASSWORD = data.azurerm_key_vault_secret.acr-service-principal-password.value
    ...
  }
  ...
}

resource "azurerm_container_registry_webhook" "webhook" {
  service_uri = "<scm URL of the azurerm_linux_web_app.web>/docker/hook"
  ...
}

I have found a way to query the scmUri using various other languages... but nothing using the azurepm provider:

After everything is deployed I can also copy the scmUri manually from Azure, but I would prefer a fully automated setup:

Deployment Center

Šimon Kocúrek
  • 1,591
  • 1
  • 12
  • 22
  • 2
    I've now also found an option to define the `scmUri` as: `https://${azurerm_linux_web_app.web.site_credential.0.username}:${azurerm_linux_web_app.web.site_credential.0.password}@${azurerm_linux_web_app.web.name}.scm.azurewebsites.net/docker/hook` – Šimon Kocúrek Feb 01 '23 at 09:53
  • 1
    You should probably write this as an answer as it looks like the only solution – Rijul Gupta May 28 '23 at 05:06

0 Answers0