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:
- REST: https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/list-publishing-credentials
- Bicep: https://github.com/Azure/bicep/discussions/3352#discussioncomment-976818
- Pulumi: Add Azure Web App Service web hook to Azure Container Registry for continuous deployment
After everything is deployed I can also copy the scmUri
manually from Azure, but I would prefer a fully automated setup: