When running my terraform deployment, i want to pull a function app from a remote git server. In the same terraform template i deploy a docker image from a private registry with no problem. I just can't find how to deploy the function app from a remote git server.
Asked
Active
Viewed 691 times
1 Answers
0
Actually, there is no property for Azure function to set the GitHub repository in Terraform. You can see all properties support in Azure Function.
But you can take the use of Azure CLI and provisioner "local-exec" in Terraform. Take a look at the steps in Terraform module for Azure FunctionApp and use the Azure CLI command az functionapp deployment source config
instead of the CLI command inside the code. Then the provisioner "local-exec" will look like below:
provisioner "local-exec" {
command = "${var.git_enabled ? join("", list("az functionapp deployment source config --ids ", azurerm_function_app.funcapp.id), " --repo-url github_URI", " --branch master --manual-integration") : "true"}"
}

Walter Gill
- 33
- 6

Charles Xu
- 29,862
- 2
- 22
- 39
-
Thank you for your answer. I had not any success with your suggested string. But your hint to the documentation already helped. I needed to add "configure". "az functionapp deployment source configure --ids " ... The connection with the git server seems to work, but there is no http-trigger set. So something still seems to be wrong but heading the right direction – Walter Gill Jun 11 '19 at 16:36
-
So i guess the problem now is, that my app is in Java and my deployment does not account for that. If you add the missing "config" in your solution i accept it as resolved. – Walter Gill Jun 11 '19 at 16:54
-
@WalterGill You can follow the steps in [Function in Java](https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven) to set your own triggers. – Charles Xu Jun 12 '19 at 06:34
-
@WalterGill Are you sure your application works fine locally? – Charles Xu Jun 12 '19 at 07:53
-
@CharelsXu My function even runs fine in Azure after deploying it from vs-code. I'm pretty sure my terraform template for the function-app is wrong somewhere. – Walter Gill Jun 12 '19 at 08:46
-
So, when i do the deployment from GIT it just copies my source code to te www-root. This means the app is not build. Is there a way to alter the exec-command to pull build and then deploy the app? – Walter Gill Jun 12 '19 at 10:24